To enable highly automated manufacturing and net-zero carbon emissions, manufacturers have invested heavily in smart manufacturing. Sustainable and smart manufacturing involves improving the efficiency and environmental sustainability of various manufacturing operations such as resource allocation, data collecting and monitoring, and process control. Recently, a lot of artificial intelligence and optimization applications based on smart grid systems have improved the energy usage efficiency in various manufacturing operations. Therefore, this survey collects recent works on applications of artificial intelligence and optimization for smart grids in smart manufacturing and analyzes their features, requirements, and challenges. In addition, potential trends and further challenges for the integration of smart grids with renewable energies for smart manufacturing, applications of 5G and B5G (beyond 5G) technologies in the SG system, and next-generation smart manufacturing systems are discussed to provide references for further research.