1 If you cannot connect to the localhost database (initialize the installation, forget the password).
Stop the MySQL database.
1 sudo/usr/local/mysql/support-files/mysql.server stop2// when stop failed see below how to use Mac The activity indicator stops the service.
Enter safe Mode. Said to be safe mode, in fact is super dangerous mode! If you are modifying locally, that's fine; if it's on the server, you have to make sure that no one is logged in to the system at this time. Because once in safe mode, anyone can log in to MySQL using any password and can perform whatever action they want to do.
1 // path to MySQL Safe mode under Linux and OSX systems/usr/local/mysql/bin/mysqld_safe 2 Sudo/usr/local/mysql/bin/mysqld_safe--skip-grant-tables
Open a new terminal.
1 mysql-u root-p2// If this is the first time you will probably not be able to use MySQL directly and access it through an absolute path. i.e. 3 /usr/local/mysql/bin/mysql-u root-p
To modify the root user password
// Switch Database // view the fields of the user table UPDATE mysql.user SET Authentication_string=password ('123456'where user=' root'// Change the root user password to 123456
After success, refresh causes the configuration to take effect
1 flush privileges;
And finally start MySQL.
1 sudo/usr/local/mysql/support-files/mysql.server start
2 is the MySQL database can be opened remotely remote access to two ways (change the table method) and (authorization method).
Http://www.jb51.net/article/85218.htm
Change Table Method:
Mysql-u root-p//log in as root user MySQLMysql>use MySQL;//Switch to mysq L databaseMysql>update UserSetHost ='%' whereuser ='Root';//Allow IP address accessMysql>SelectHost, user fromUser//To see if the update was successfulMysql>flush privileges;//Refreshing the databaseMysql>exit//Exit
Authorization law: (omitted)
3 Telnet.
Note the port number
Fool operation when using client login.
The use of terminals is:
1 mysql-u user name-p-h IP address-p port number
MySQL Database remote connection