今天在更换数据库的时候,很多命令不记得了,来做个笔记
以下内容来源于WordPress官网。
You can create MySQL users and databases quickly and easily by running mysql from the shell. The syntax is shown below and the dollar sign is the command prompt:
1 | $ mysql -u adminusername -p |
The example shows:
that root is also the adminusername. It is a safer practice to choose a so-called “mortal” account as your mysql admin, so that you are not entering the command “mysql” as the root user on your system. (Any time you can avoid doing work as root you decrease your chance of being exploited.)
The name you use depends on the name you assigned as the database administrator using mysqladmin.
wordpress or blog are good values for databasename. wordpress is a good value for wordpressusername but you should realize that, since it is used here, the entire world will know it, too.
hostname will usually be localhost. If you don’t know what this value should be, check with your system administrator if you are not the admin for your WordPress host.
If you are the system admin, consider using a non-root account to administer your database.password should be a difficult-to-guess password, ideally containing a combination of upper- and lower-case letters, numbers, and symbols.
One If you need to write these values somewhere, avoid writing them in the system that contains the things protected by them. You need to remember the value used for databasename, wordpressusername, hostname, and password.
Of course, since they are already in (or will be shortly) your wp-config.php file, there is no need to put them somewhere else, too.
在MySQL8.0版本中,不再支持一条语句同时创建用户和赋予权限,需要分成两句:
1 | mysql> CREATE USER "wordpressusername"@"hostname" IDENTIFIED BY "password"; |
再次更新,部分php版本无法成功连接MySQL8.0,是因为密码的原因:
1 | mysql>CREATE USER 'username'@'host' IDENTIFIED with mysql_native_password BY 'password'; |