Starting and Stopping MySQL Automatically initialized using  mysqld --initialize , either manually or using an installer that does not give you the option of specifying a password during the install operation. Because the password exists, you must use it to connect to the server. But because the password is expired, you cannot use the account for any purpose other than to choose a new password, until you do choose one. 1. If you do not know the initial random password, look in the server error log. 3. Choose a new password to replace the random password: shell>  mysql -u root -p Enter password:  (enter the random root password here) 2. Connect to the server as  root  using the password: mysql>  ALTER USER ’root’@’localhost’ IDENTIFIED BY ’ root-password ’; •If the  root  account exists but has no password, connect to the server as  root  using no password, then assign a password. This is the case if you initialized the data directory using  mysqld --initialize- insecure . 1. Connect to the server as  root  using no password: 2. Assign a password: shell>  mysql -u root --skip-password mysql>  ALTER USER ’root’@’localhost’ IDENTIFIED BY ’ root-password ’; After assigning the  root  account a password, you must supply that password whenever you connect to the server using the account. For example, to connect to the server using the  mysql  client, use this command: To shut down the server with  mysqladmin , use this command: shell>  mysql -u root -p Enter password:  (enter root password here) shell>  mysqladmin -u root -p shutdown Enter password:  (enter root password here) Note For additional information about setting passwords, see Section 6.2.14, “Assigning Account Passwords” . If you forget your  root  password after setting it, see Section B.3.3.2, “How to Reset the Root Password” . To set up additional accounts, see Section 6.2.8, “Adding Accounts, Assigning Privileges, and Dropping Accounts” . 2.10.5 Starting and Stopping MySQL Automatically This section discusses methods for starting and stopping the MySQL server. Generally, you start the  mysqld  server in one of these ways: •Invoke  mysqld  directly. This works on any platform. •On Windows, you can set up a MySQL service that runs automatically when Windows starts. See Section 2.3.4.8, “Starting MySQL as a Windows Service” . 260