ubuntu中mysql的安装及基本配置

sudo apt install mysql-server

sudo mysql_secure_installation #基础安全配置

sudo mysql

mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;

mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’; #使root用户使用密码也可以登录mysql

mysql> FLUSH PRIVILEGES;

mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; #创建名为wordpress的数据库

mysql> GRANT ALL ON wordpress.* TO ‘wordpressuser’@‘localhost’ IDENTIFIED BY ‘password’; #创建wordpressuser用户,赋予其wordpress数据库所有权限,且用户密码为password