[code language=”bash”]
sudo mysql_install_db
sudo /etc/init.d/mysql start
# 参考
#/etc/init.d/mysql start|stop|restart|reload|force-reload|status

# To start repair MySQL, we need to stop it first
## Script to stop mysql server
sudo /etc/init.d/mysql stop

## Start another mysqld instance, but this does not check grants
## (grants are access rights in database terminology).
## This mode is only for troubleshooting, please do NOT use it on a day to day basis
sudo mysqld_safe –skip-grant-tables &

Now start mysql-admin or your favourite MySQL administrative tool, you should be able to login with any user, without password and with full root privileges.
#I haven’t tried adding users and grants, will come back and edit this

Grant ALL on mysql.* TO root;

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY “123456”;

# When you’re done adding users and grants, close the client and run
sudo /etc/init.d/mysql stop

# start normal MySQL Daemon (aka server in Linux terminology)
sudo mysqld

# test your new users and passwords with mysql-admin
# Or, if you like command line:
mysql -u your_username -p
# you will be prompted for password


1. mysql: access denied for user @locahost



  1. 我也是很久没碰mysql了。这个是去年年初扔在草稿箱里的。你原来的网站也大都是php+mysql的吧。


电子邮件地址不会被公开。 必填项已用*标注