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

Recommend

WeChat applet learning notes: page configuration and routing

I have been studying and reviewing the developmen...

Steps for installing MySQL 8.0.16 on Windows and solutions to errors

1. Introduction: I think the changes after mysql8...

Summary of commonly used operators and functions in MySQL

Let’s build the data table first. use test; creat...

An article to give you a deep understanding of Mysql triggers

Table of contents 1. When inserting or modifying ...

In-depth understanding of Vue's data responsiveness

Table of contents 1. ES syntax getter and setter ...

Detailed explanation of CSS3 rotating cube problem

3D coordinate concept When an element rotates, it...

Example of how to set up a Linux system to automatically run a script at startup

Preface Hello everyone, I am Liang Xu. At work, w...

JS+Canvas draws a lucky draw wheel

This article shares the specific code of JS+Canva...

Some tips on deep optimization to improve website access speed

Some tips for deep optimization to improve websit...

Nginx reverse proxy and load balancing practice

Reverse Proxy Reverse proxy refers to receiving t...

Introduction to the role of HTML doctype

Document mode has the following two functions: 1. ...

CSS sets Overflow to hide the scroll bar while allowing scrolling

CSS sets Overflow to hide the scroll bar while al...

How to implement scheduled backup of MySQL database

1. Create a shell script vim backupdb.sh Create t...

Using cursor loop to read temporary table in Mysql stored procedure

cursor A cursor is a method used to view or proce...

Common methods and problems of Docker cleaning

If you use docker for large-scale development but...