$sudo mysql -u root //修改用户root的密码,使用sudo登陆 mysql> USE mysql; //切换到mysql库 mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> exit; $sudo service mysql restart //重启mysql
$mysql -uroot -p //不使用sudo进入mysql mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';//设置root用户的密码为root
默认内容如下: // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost'); 将其修改为: // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'root'); /** MySQL database password */ define('DB_PASSWORD', 'root'); /** MySQL hostname */ define('DB_HOST', 'localhost');