Mysql 5.7.17 logon to mysql after installation, 5.7.17mysql

Source: Internet
Author: User

Mysql 5.7.17 logon to mysql after installation, 5.7.17mysql

The installation of mysql-5.7.17 is introduced below the article, you can refer. Next we will introduce the tutorial of logging on to Mysql after mysql 5.7.17 is installed. Let's take a look.

A random password is generated when you run./bin/mysqld-initialize to initialize the database. For example:

[Note] A temporary password is generated for root@localhost: Wtng#?e&S5,-

In this example, the password is Wtng #? E & S5,-. Use this password to log on to mysql for the first time.

$ /usr/local/mysql/bin/mysql -uroot -p'Wtng#?e&S5,-'

After logging on to mysql, set the new password to "mypassword ".

mysql> set password = password('mypassword');

There is another way, regardless of the initial password. Under the root user, modify the my. cnf file and skip the password to log on directly. To log on to mysql, use the mysql command line to change the password. This method also applies when you forget the mysql password and need to change the password.

$ Vi/etc/my. cnf [mysqld] Add: skip-grant-tables $ service mysqld restart in the configuration Area

You can log on directly and change the 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 my. cnf, remove the added skip-grant-tables, restart the mysqld service, and log on with the new password.

Source code installation mysql-5.7.17 (centos-6.8-minimal) Method

Official documentation

Http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

Preparations

1. Install wget, gcc, gcc-c ++, bison, ncurses, and ncurses-devel.

$ yum install –y wget gcc gcc-c++ bison ncurses ncurses-devel 

2. Install 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_000059_0. Download and decompress it to a directory and specify it when installing mysql. In addition, the mysql official website provides the mysql source code 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 the mysql source code package (excluding boost) and decompress it.

$ 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 later versions use./bin/mysqld -- initialize to initialize the database;
After initialization, A random password is generated. for example: [Note] A temporary password is generated for root @ localhost: Wtng #? E & S5 ,-.
./Bin/mysql_ssl_rsa_setup requires openssl support. It is used to enable ssl connections for data volumes and requires further configuration.

4. Configuration File

$ cp support-files/my-default.cnf /etc/my.cnf$ vim !$

Modified:

basedir = /usr/local/mysqldatadir = /data/mysqlport = 3306socket = /tmp/mysql.sock

5. Start the script

$ cp support-files/mysql.server /etc/init.d/mysqld$ vim !$

Modified:

 basedir = /usr/local/mysql  datadir = /data/mysql

There are two startup scripts:/usr/local/mysql/bin/mysqld_safe and/usr/local/mysql/support-files/mysql. server (that is,/etc/init. d/mysqld ). When mysqld is started, mysqld_safe is started at the same time. mysqld_safe monitors the mysqld service, records error logs, and restarts mysqld when it is stopped due to a fault.

6. Start the mysqld service

/etc/init.d/mysqld start

If you want to set boot start:

$ chkconfig --add mysqld$ chkconfig mysqld on$ service mysqld start

The above is a simple tutorial on logging on to Mysql after mysql 5.7.17 is installed. I hope it will help you. If you have any questions, please leave a message and I will reply to you in time. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.