We formulate axion-electrodynamics and magnetohydrodynamics (MHD) in the cosmological context assuming weak gravity. The two formulations are made for a general scalar field with general f(??)-coupling, and an axion as a massive scalar field with ??2-coupling, with the helical electromagnetic field. The ??-dynamo term appears naturally from the helical coupling in the MHD formulation. In the presence of the electromagnetic coupling, however, the Schr??dinger and hydrodynamic formulations of the coherently oscillating axion are not available for the conventional ?? coupling; instead, ??2 coupling allows successful formulations preserving the dark matter nature of the axion to nonlinear order. In the MHD formulation, direct couplings between the scalar and electromagnetic fields appear only for nonideal MHD. We study gravitational and magnetic instabilities of the scalar field and axion MHDs.