When you run the./bin/mysqld cinitialize Initialize the database, a random password is generated, as an example:
[Note] A temporary password is generated for [email protected]: wtng#?e&s5,-
Example password is wtng#?e&s5,-, first login mysql, with this password.
$/usr/local/mysql/bin/mysql-uroot-p ' wtng#?e&s5,-'
After logging in to MySQL, set the new password to "MyPassword".
mysql> Set Password = password (' mypassword ');
There is another way to do this without having to control what the initial password is, under root user, modify the my.cnf file, and skip the password to log in directly. Log in to MySQL, and then use the MySQL command line to change the password. This method can also be used to forget the MySQL password, need to change the password situation.
$ vi/etc/my.cnf
[MYSQLD] Configuration area add:
Skip-grant-tables
$ Service Mysqld Restart
You can log in directly and then change your password.
$/usr/local/mysql/bin/mysql-uroot
mysql> Update user Set Authentication_string=password (' MyPassword ') where user= ' root ';
Mysql> quit
Log out of MySQL, modify the my.cnf, remove the added skip-grant-tables, restart the mysqld service, and sign in with the new password.
Source code Installation mysql-5.7.17 (Centos-6.8-minimal) method
Official documents
Http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html
Preparatory work
1. Install wget, gcc, gcc-c++, bison, ncurses, Ncurses-devel
$ yum Install Cy wget gcc gcc-c++ bison ncurses ncurses-devel
2. Installing CMake
$ cd/usr/local/src/
$ wget https://cmake.org/files/v3.7/cmake-3.7.1.tar.gz
$ tar zxvf cmake-3.7.1.tar.gz
$ CD cmake-3.7.1
$./bootstrap && gmake && gmake Install
3. This version requires boost_1_59_0, download unzip to a directory, install MySQL need to specify. In addition, the MySQL website provides a MySQL source package containing boost.
$ wget https://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
$ tar zxf boost_1_59_0.tar.gz
$ MV boost_1_59_0/usr/local/
4. Download MySQL source package (without boost) and unzip
$ cd/usr/local/src/
$ wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz
$ tar zxvf mysql-5.7.17.tar.gz
installation process
1. Create users and Groups Mysql:mysql
$ groupadd MySQL
$ useradd-r-G mysql-s/sbin/nologin MySQL
2. Compile and install MySQL
$ cd/usr/local/src/mysql-5.7.17
$ mkdir Build
$ CD Build
$ cmake.. \
-dcmake_install_prefix=/usr/local/mysql \
-DSYSCONFDIR=/ETC \
-dmysql_datadir=/data/mysql \
-dmysql_user=mysql \
-dmysql_unix_addr=/tmp/mysql.sock \
-dmysql_tcp_port=3306 \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_partition_storage_engine=1 \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dextra_charsets=all \
-denabled_local_infile=1 \
-dwith_boost=/usr/local/boost_1_59_0
$ make && make install
3. Initialization
$ cd/usr/local/mysql
$ chown-r mysql:mysql.
$ mkdir-p/data/mysql
$ chown-r Mysql.mysql/data/mysql
$./bin/mysqld--initialize \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/data/mysql
$./bin/mysql_ssl_rsa_setup--datadir=/data/mysql
5.7.6 and above use./bin/mysqld--initialize initialize the database;
After initialization, a random password is generated, example: [Note] A temporary password is generated for [email protected]: WTNG#?E&S5,-。
./bin/mysql_ssl_rsa_setup requires OpenSSL support to enable the data volume SSL connection and requires further configuration.
4. Configuration files
$ CP support-files/my-default.cnf/etc/my.cnf
$ vim!$
Modification section:
Basedir =/usr/local/mysql
DataDir =/data/mysql
Port = 3306
Socket =/tmp/mysql.sock
5. Start the script
$ CP Support-files/mysql.server/etc/init.d/mysqld
$ vim!$
Modification section:
Basedir =/usr/local/mysql
DataDir =/data/mysql
There are two startup scripts, namely/usr/local/mysql/bin/mysqld_safe and/usr/local/mysql/support-files/mysql.server (i.e./etc/init.d/mysqld). When Mysqld is started, Mysqld_safe starts simultaneously, MYSQLD_SAFE monitors the MYSQLD service, logs the error log, and restarts it when the mysqld is stopped because of a failure.
6. Start the MYSQLD service
/etc/init.d/mysqld start
If you want to set up boot:
$ chkconfig--add mysqld
$ chkconfig mysqld on
$ service Mysqld Start
MySQL 5.7.17 after installation login MySQL Tutorial method