Ionic solutions are mixtures of interacting anions and cations. They hardly resemble dilute gases of uncharged noninteracting point particles described in elementary textbooks. Biological and electrochemical solutions have many components that interact strongly as they flow in concentrated environments near electrodes, ion channels, or active sites of enzymes. Interactions in concentrated environments help determine the characteristic properties of electrodes, enzymes, and ion channels. Flows are driven by a combination of electrical and chemical potentials that depend on the charges, concentrations, and sizes of all ions, not just the same type of ion. We use a variational method EnVarA (energy variational analysis) that combines Hamilton's least action and Rayleigh's dissipation principles to create a variational field theory that includes flow, friction, and complex structure with physical boundary conditions. EnVarA optimizes both the action integral functional of classical mechanics and the dissipation functional. These functionals can include entropy and dissipation as well as potential energy. The stationary point of the action is determined with respect to the trajectory of particles. The stationary point of the dissipation is determined with respect to rate functions (such as velocity). Both variations are written in one Eulerian (laboratory) framework. In variational analysis, an "extra layer" of mathematics is used to derive partial differential equations. Energies and dissipations of different components are combined in EnVarA and Euler-Lagrange equations are then derived. These partial differential equations are the unique consequence of the contributions of individual components. The form and parameters of the partial differential equations are determined by algebra without additional physical content or assumptions. The partial differential equations of mixtures automatically combine physical properties of individual (unmixed) components. If a new component is added to the energy or dissipation, the Euler-Lagrange equations change form and interaction terms appear without additional adjustable parameters. EnVarA has previously been used to compute properties of liquid crystals, polymer fluids, and electrorheological fluids containing solid balls and charged oil droplets that fission and fuse. Here we apply EnVarA to the primitive model of electrolytes in which ions are spheres in a frictional dielectric. The resulting Euler-Lagrange equations include electrostatics and diffusion and friction. They are a time dependent generalization of the Poisson-Nernst-Planck equations of semiconductors, electrochemistry, and molecular biophysics. They include the finite diameter of ions. The EnVarA treatment is applied to ions next to a charged wall, where layering is observed. Applied to an ion channel, EnVarA calculates a quick transient pile-up of electric charge, transient and steady flow through the channel, stationary "binding" in the channel, and the eventual accumulation of salts in "unstirred layers" near channels. EnVarA treats electrolytes in a unified way as complex rather than simple fluids. Ad hoc descriptions of interactions and flow have been used in many areas of science to deal with the nonideal properties of electrolytes. It seems likely that the variational treatment can simplify, unify, and perhaps derive and improve those descriptions.