The magnetic field of solar-like, cool stars shapes their corona and astrosphere and can lead to intriguing magnetic interactions with close-in planets. Such stellar magnetic fields are thought to be sustained by a dynamo process operating in their internal turbulent convective regions. They are generally observed to be variable in time, as it is the case for the Sun with its mysterious magnetic cycle of 11 years. A dynamical dynamo field naturally triggers a dynamical corona. Close-in exoplanets around magnetic stars are thus likely to be subject to a strongly varying magnetic interaction, which can lead to potentially observable emissions, planetary evaporation, or even planet migration due to magnetic torques. I will present here a series of work tackling the various aspects of the magnetism of a star and its environment, based on massively parallel numerical simulations using various magnetohydrodynamics formulations. I will first give a brief tour of our understanding of the origin of the cyclicality of solar-like magnetic fields, and present very recent results showing a systematic modulation of the cycle period with the global parameters of the modelled star (rotation, luminosity. Then, I will present state-of-the-art 3D numerical simulations of stellar winds capable of using observed (or modelled) complex and time-varying magnetic topologies. I will finally explore the implication of stellar magnetism on close-in planets using global 3D models of star-planet systems. I will lay out the basic principles behind magnetic star-planet interaction, which resemble planet-satellite interactions. I will conclude with a series of numerical simulations that can be used to parametrize the observable effects of the magnetic interaction, and as a result can help constraining the hypothetical magnetic field of close-in exoplanets.