Tutorial on logging into MySQL after installing Mysql 5.7.17

Tutorial on logging into MySQL after installing Mysql 5.7.17

The installation of mysql-5.7.17 is introduced below the article, you can refer to it. Here I will introduce to you the tutorial on how to log in to MySQL after installing MySQL 5.7.17. Let’s take a look.

When you run ./bin/mysqld –initialize to initialize the database, a random password is generated. For example:

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

The password in the example is Wtng#?e&S5,- . Use this password when you log in to MySQL for the first time.

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

After logging into mysql, set a new password to "mypassword".

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

There is another way. Don't worry about the initial password. Under the root user, modify the my.cnf file and skip the password to log in directly. After logging into mysql, use the mysql command line to change the password. This method is also suitable for situations where you forget your MySQL password and need to change it.

$ vi /etc/my.cnf
  [mysqld] Configuration area added:
  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 my.cnf, remove the added skip-grant-tables, restart the mysqld service, and log in with the new password.

How to install mysql-5.7.17 (centos-6.8-minimal) from source code

Official Documentation

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

Preparation

1. Install wget, gcc, gcc-c++, bison, ncurses, 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_1_59_0, download and unzip it to a certain directory, which needs to be specified when installing MySQL. In addition, the MySQL official website provides MySQL source code packages 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 package (excluding boost) and unzip 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 user and group 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

For versions 5.7.6 and above, use ./bin/mysqld --initialize to initialize the database.
After initialization, a random password is generated, example: [Note] A temporary password is generated for root@localhost: Wtng#?e&S5,-.
./bin/mysql_ssl_rsa_setup requires openssl support to enable data volume ssl connection and requires further configuration.

4. Configuration File

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

Modified part:

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 !$

Modified part:

 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 (that is, /etc/init.d/mysqld). When you start mysqld, mysqld_safe is started at the same time. mysqld_safe monitors the mysqld service, records error logs, and restarts mysqld if it stops due to a failure.

6. Start the mysqld service

/etc/init.d/mysqld start

To set it to start at boot:

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

The above is the tutorial on how to log in to MySQL after installing Mysql 5.7.17. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • A quick solution to the first login failure in mysql5.7.20
  • Solution to the root password login problem in MySQL 5.7
  • How to install the green version of MySQL Community Server 5.7.16 and implement remote login
  • Solve the problem of ERROR 1045 (28000): Access denied for user ''root''@''localhost'' when logging in after installing MySQL 5.7.17 on Ubuntu 16.04
  • Solve the problem of being unable to log in after installing MySQL 5.7 without a data folder
  • Solution to the problem of Access denied for user'root'@'localhost' (using password: YES) in MySQL 8.0 login under win10

<<:  WeChat applet canvas implements signature function

>>:  A brief introduction to the simple use of CentOS7 firewall and open ports

Blog    

Recommend

Understanding of haslaylout and bfc parsing

1. haslayout and bfc are IE-specific and standard ...

Detailed explanation of the use of React.cloneElement

Table of contents The role of cloneElement Usage ...

Detailed steps to install xml extension in php under linux

Installing XML extension in PHP Linux 1. Enter th...

A Brief Analysis on the Time Carrying Problem of MySQL

The default time type (datetime and timestamp) in...

MySQL insert json problem

MySQL 5.7.8 and later began to support a native J...

Detailed explanation of Vue filters

<body> <div id="root"> <...

How to move a red rectangle with the mouse in Linux character terminal

Everything is a file! UNIX has already said it. E...

How to implement import and export mysql database commands under linux

1. Export the database using the mysqldump comman...

Postman automated interface testing practice

Table of contents Background Description Creating...

MySQL 8.0.25 installation and configuration tutorial under Linux

The latest tutorial for installing MySQL 8.0.25 o...

How to convert MySQL horizontally to vertically and vertically to horizontally

Initialize Data DROP TABLE IF EXISTS `test_01`; C...

Detailed explanation of Linux CPU load and CPU utilization

CPU Load and CPU Utilization Both of these can re...

Ubuntu MySQL version upgraded to 5.7

A few days ago, the library said that the server ...

Comprehensive understanding of HTML Form elements

As shown below: XML/HTML CodeCopy content to clip...

jQuery implements HTML element hiding and display

Let's imitate Taobao's function of displa...