Open the command-line mysql client on the server using the root account. Then you will want to run the following two commands, to see what the root user host is set to already: use mysql; select host, user from user; Here’s an example of the output on my database, which is pretty much the default settings. Also: Some versions of MySQL set their passwords to expire by default, even the root password! If the password expires, Kodi cannot access the database and the TV Series and Movies libraries will disappear. To avoid this and/or fix it after it happens, make sure the account's password does not expire.
- By default, when you install XAMPP in your windows machine or mac, the root password for the MySQL is set to empty. But this is not recommended, as the MySQL database without a password will be accessible to everyone. To avoid this, a proper/secure password must be set to the user root. To do it in XAMPP, there are two ways.
- Once you have MySQL downloaded in PC or Mac. Follow below steps to install, configure and use MySQL. Double click on MySQL setup file and start installation. Wait until MySQL is installed completely. During installation you may be prompted for MySQL root user name password. This is the MySQL super user credentials. Set them and make them secure.
If you have never assigned a root
password for MySQL, the server does not require a password at all for connecting as root
. However, this is insecure. For instructions on assigning a password, see Section 2.10.4, “Securing the Initial MySQL Account”.
If you know the root
password and want to change it, see Section 13.7.1.1, “ALTER USER Statement”, and Section 13.7.1.10, “SET PASSWORD Statement”.
If you assigned a root
password previously but have forgotten it, you can assign a new password. The following sections provide instructions for Windows and Unix and Unix-like systems, as well as generic instructions that apply to any system.
B.3.3.2.1 Resetting the Root Password: Windows Systems
On Windows, use the following procedure to reset the password for the MySQL 'root'@'localhost'
account. To change the password for a root
account with a different host name part, modify the instructions to use that host name.
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.
Save the file. This example assumes that you name the file
C:mysql-init.txt
.Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the
init_file
system variable set to name the file (notice that the backslash in the option value is doubled):If you installed MySQL to a different location, adjust the cd command accordingly.
The server executes the contents of the file named by the
init_file
system variable at startup, changing the'root'@'localhost'
account password.To have server output to appear in the console window rather than in a log file, add the
--console
option to the mysqld command.If you installed MySQL using the MySQL Installation Wizard, you may need to specify a
--defaults-file
option. For example:The appropriate
--defaults-file
setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose theProperties
option. ThePath to executable
field contains the--defaults-file
setting.After the server has started successfully, delete
C:mysql-init.txt
.
You should now be able to connect to the MySQL server as root
using the new password. Stop the MySQL server and restart it normally. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.
B.3.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems
On Unix, use the following procedure to reset the password for the MySQL 'root'@'localhost'
account. To change the password for a root
account with a different host name part, modify the instructions to use that host name.
The instructions assume that you start the MySQL server from the Unix login account that you normally use for running it. For example, if you run the server using the mysql
login account, you should log in as mysql
before using the instructions. Alternatively, you can log in as root
, but in this case you must start mysqld with the --user=mysql
option. If you start the server as root
without using --user=mysql
, the server may create root
-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups. If that happens, you must either change the ownership of the files to mysql
or remove them.
Set Root Password Mysql Mac Command
Log on to your system as the Unix user that the MySQL server runs as (for example,
mysql
).Stop the MySQL server if it is running. Locate the
.pid
file that contains the server's process ID. The exact location and name of this file depend on your distribution, host name, and configuration. Common locations are/var/lib/mysql/
,/var/run/mysqld/
, and/usr/local/mysql/data/
. Generally, the file name has an extension of.pid
and begins with eithermysqld
or your system's host name.Stop the MySQL server by sending a normal
kill
(notkill -9
) to the mysqld process. Use the actual path name of the.pid
file in the following command:Use backticks (not forward quotation marks) with the
cat
command. These cause the output ofcat
to be substituted into thekill
command.Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.
Save the file. This example assumes that you name the file
/home/me/mysql-init
. The file contains the password, so do not save it where it can be read by other users. If you are not logged in asmysql
(the user the server runs as), make sure that the file has permissions that permitmysql
to read it.Start the MySQL server with the
init_file
system variable set to name the file:The server executes the contents of the file named by the
init_file
system variable at startup, changing the'root'@'localhost'
account password.Other options may be necessary as well, depending on how you normally start your server. For example,
--defaults-file
may be needed before theinit_file
argument.After the server has started successfully, delete
/home/me/mysql-init
.
Set Root Password Mysql Macros
You should now be able to connect to the MySQL server as root
using the new password. Stop the server and restart it normally.
B.3.3.2.3 Resetting the Root Password: Generic Instructions
The preceding sections provide password-resetting instructions specifically for Windows and Unix and Unix-like systems. Alternatively, on any platform, you can reset the password using the mysql client (but this approach is less secure):
Stop the MySQL server if necessary, then restart it with the
--skip-grant-tables
option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such asALTER USER
andSET PASSWORD
. Because this is insecure, if the server is started with the--skip-grant-tables
option, it also disables remote connections by enablingskip_networking
.Connect to the MySQL server using the mysql client; no password is necessary because the server was started with
--skip-grant-tables
:In the
mysql
client, tell the server to reload the grant tables so that account-management statements work:Then change the
'root'@'localhost'
account password. Replace the password with the password that you want to use. To change the password for aroot
account with a different host name part, modify the instructions to use that host name.
You should now be able to connect to the MySQL server as root
using the new password. Stop the server and restart it normally (without the --skip-grant-tables
option and without enabling the skip_networking
system variable).
By default, when you install XAMPP in your windows machine or mac, the root
password for the MySQL is set to empty. But this is not recommended, as the MySQL database without a password will be accessible to everyone. To avoid this, a proper/secure password must be set to the user root
. To do it in XAMPP, there are two ways.
Method 1: reset XAMPP MySQL root password through web interface:
After you started your XAMPP server, go to the browser and type the URL:
(incase you’ve modified XAMPP server port, you need to include that port number also in previous URL). The security page will be shown where you can change the
password for MySQL. This will update the phpMyAdmin config also.
Method 2: reset XAMPP MySQL root password through SQL update:
- Start the Apache Server and MySQL instances from the XAMPP control panel.
- After the server started, open any web browser and give
(if you are running XAMPP on 8090 port). This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.
- In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.
- Now type the following query in the textarea and click GoUPDATE mysql.user SET Password=PASSWORD('password')WHERE User='root';FLUSH PRIVILEGES;
- Now you will see a message saying that the query has been executed successfully.
- If you refresh the page, you will be getting a error message. This is because the phpMyAdmin configuration file is not aware of our newly set root passoword. To do this we have to modify the phpMyAdmin config file.
- Open the file