MySQL basic knowledge of the essence of summary _2 (install linux version mysql5.7)

Relatively speaking, better windows installed directly on the linux version of it

Prepare: 1 virtual machine vmware; 2. redhat 6.5 system; 3. Replace the redhat source of yum (yum because of redhat for a fee, the cache centos version, and then you install yum, install version 5.1 is installed with yum install mysql so discard the direct use rpm installation, rpm installation will be a lot more disgusting dependencies) 4. go to the official website to download mysql5.7 .tar file which contains a lot of the rpm package, to ensure that the lack of rpm when the dependencies are inside.

The above operation, do some on their own, and I believe a lot of this on the network installation tutorial, I will not say, playing directly based command bar

 

1. After the installation is completed as follows:

  Permissions:  chown MySQL : MySQL - R & lt / var / lib / MySQL

  Initialization MySQL:  mysqld - the initialize

  Start MySQL: systemctl the X-Start mysqld (6 version of the system, is to start service mysqld start)

  View MySQL running status: systemctl Status mysqld

 

However, a lot of mistakes when I happened ah operation:

[root@localhost lib]# mysqld initialize
2019-07-04T10:26:48.489489Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-04T10:26:48.514630Z 0 [Note] mysqld (mysqld 5.7.26) starting as process 40610 ...
2019-07-04T10:26:48.532526Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2019-07-04T10:26:48.532606Z 0 [ERROR] Aborting

2019-07-04T10:26:48.533289Z 0 [Note] Binlog end
2019-07-04T10:26:48.534863Z 0 [Note] mysqld: Shutdown complete

Then try to switch to the mysql user initialization why?

[root@localhost lib]# ps -ef|grep mysql
root 42516 18145 4 03:28 pts/1 00:00:00 grep mysql
[root@localhost lib]# su - mysql
-bash-4.1$ mysqld initalize
-bash-4.1$ ps -ef|grep mysql
root 42517 18145 0 03:29 pts/1 00:00:00 su - mysql
mysql 42518 42517 0 03:29 pts/1 00:00:00 -bash
mysql 42558 42518 1 03:29 pts/1 00:00:00 ps -ef
mysql 42559 42518 0 03:29 pts/1 00:00:00 grep mysql

Finally, check to see what other people said so:

This is because at the time of testing, the use of root to start. From the security point of view, it is not recommended to start with the root user.

solution:

/usr/sbin/mysqld --skip-grant-tables --skip-networking --user=root & 

Start mysql

[root@localhost lib]# service mysqld start
Starting mysqld: [ OK ]

Mysql query run state

[root@localhost lib]# service mysqld status
mysqld (pid 42668) is running...

 

Verify MySQL installation

After a successful installation of MySQL, the table will list some basic initialization, after the server is started, you can verify that MySQL is working correctly by simple tests.

Use mysqladmin tool to get the server status:

Use mysqladmin command to check the server version of linux on the binary file is located in / usr / bin directory on the Windows binary file is located in C: \ mysql \ bin.

[root@localhost lib]# mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.7.26, for Linux on x86_64

 

Execute simple SQL commands to use MySQL Client (Mysql client)

You can use the MySQL Client (Mysql client) mysql command to connect to the MySQL server, MySQL server default login password is empty, so this operation does not require a password.

Command is as follows:

[root@host]# mysql

 

 

After executing the above command output mysql> prompt, indicating that you have successfully connected to the Mysql server, you can mysql> prompt, execute SQL commands:

mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)


Mysql need to do after installation

Mysql After successful installation, the default root user password is empty, you can create the root password, use the following command:

[root@host]# mysqladmin -u root password "new_password";

Now you can connect to Mysql server with the following command:

[root@host]# mysql -u root -p Enter password:*******

[root@localhost lib]# mysqladmin -u root password root
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin:
You cannot use 'password' command as mysqld runs
with grant tables disabled (was started with --skip-grant-tables).
Use: "mysqladmin flush-privileges password '*'" instead

 

Guess you like

Origin www.cnblogs.com/txmg/p/11131059.html