安装有多种方式,可以添加源之后直接,更新源,dnf install mysql_server
也可以下载apm包之后直接 rpm install ,初次安装可能需要安装一个包。
Installing and Upgrading MySQL
Table 2.9 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone(cp from http://dev.mysql.com/doc)
Files or Resources | Location |
---|---|
Client programs and scripts | /usr/bin |
mysqld server | /usr/sbin |
Configuration file | /etc/my.cnf |
Data directory | /var/lib/mysql |
Error log file | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Value of secure_file_priv | /var/lib/mysql-files |
System V init script | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Systemd service | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Pid file | /var/run/mysql/mysqld.pid |
Unix manual pages | /usr/share/man |
Include (header) files | /usr/include/mysql |
Libraries | /usr/lib/mysql |
Socket | /var/lib/mysql/mysql.sock |
Miscellaneous support files (for example, error messages and character set files) | /usr/share/mysql |
shell> service mysqld start
然后我们就可以在mysql相关日志文件中搜索初始密码啦,查看一下目录,可以尝试下面两个命令
shell>
grep 'temporary password' /var/log/mysqld.log
shell>
grep 'temporary password' /var/log/mysql/mysqld.log
mysql -uroot -p 输入所查询到的密码即可进入熟悉的mysql
At the initial start up of the server, the following happens, given that the data directory of the server is empty:
-
The server is initialized.
-
An SSL certificate and key files are generated in the data directory.
-
The validate_password plugin is installed and enabled.
-
A superuser account
'root'@'localhost'
is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command for RHEL, Oracle Linux, CentOS, and Fedora platform:shell>
grep 'temporary password' /var/log/mysqld.log
Use the following command for SLES platform:
shell>
grep 'temporary password' /var/log/mysql/mysqld.log
The next step is to log in with the generated, temporary password and set a custom password for the superuser account:
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
MySQL's validate_password plugin is installed by default. This will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.
If something goes wrong during installation, you might find debug information in the error log file /var/log/mysqld.log
.
Compatibility with RPM Packages from Other Vendors. If you have installed packages for MySQL from your Linux distribution's local software repository, it is much preferable to install the new, directly-downloaded packages from Oracle using the package management system of your platform (yum, dnf, orzypper), as described above. The command replaces old packages with new ones to ensure compatibility of old applications with the new installation; for example, the old mysql-libs
package is replaced with the mysql-community-libs-compat
package, which provides a replacement-compatible client library for applications that were using your older MySQL installation. If there was an older version of mysql-community-libs-compat
on the system, it also gets replaced.
If you have installed third-party packages for MySQL that are NOT from your Linux distribution's local software repository (for example, packages directly downloaded from a vendor other than Oracle), you should uninstall all those packages before installing the new, directly-downloaded packages from Oracle. This is because conflicts may arise between those vendor's RPM packages and Oracle's: for example, a vendor's convention about which files belong with the server and which belong with the client library may differ from that used for Oracle packages. Attempts to install an Oracle RPM may then result in messages saying that files in the RPM to be installed conflict with files from an installed package.
Debug Package. A special variant of MySQL Server compiled with the debug package has been included in the server RPM packages. It performs debugging and memory allocation checks and produces a trace file when the server is running. To use that debug version, start MySQL with /usr/sbin/mysqld-debug
, instead of starting it as a service or with /usr/sbin/mysqld
. See Section 24.5.3, “The DBUG Package” for the debug options you can use.
Rebuilding RPMs from source SRPMs. Source code SRPM packages for MySQL are available from the MySQL Yum repository. They can be used as-is to rebuild the MySQL RPMs with the standard rpmbuild tool chain.
root
passwords for pre-GA releases. For MySQL 5.7.4 and 5.7.5, the initial random root
password is written to the .mysql_secret
file in the directory named by the HOME
environment variable. When trying to access the file, bear in mind that depending on operating system, using a command such as sudomay cause the value of HOME
to refer to the home directory of the root
system user . .mysql_secret
is created with mode 600 to be accessible only to the system user for whom it is created. Before MySQL 5.7.4, the accounts (including root
) created in the MySQL grant tables for an RPM installation initially have no passwords; after starting the server, you should assign passwords to them using the instructions in Section 2.10, “Postinstallation Setup and Testing”."