Mysql Learning-installation
First, extract the mysql installation package. Note that the downloaded mysql package must be consistent with the operating system version.
[root@node1 soft] # ls
Mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft] # ls-l
Total 600552
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
[root@node1 soft] # tar-xvf mysql-5.7.11-1.el5.i686.rpm-bundle.tar
Mysql-community-libs-5.7.11-1.el5.i686.rpm
Mysql-community-common-5.7.11-1.el5.i686.rpm
Mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
Mysql-community-server-5.7.11-1.el5.i686.rpm
Mysql-5.7.11-1.el5.i686.rpm
Mysql-community-test-5.7.11-1.el5.i686.rpm
Mysql-community-devel-5.7.11-1.el5.i686.rpm
Mysql-community-client-5.7.11-1.el5.i686.rpm
Mysql-community-embedded-5.7.11-1.el5.i686.rpm
Mysql-community-embedded-devel-5.7.11-1.el5.i686.rpm
Second, install mysql
[root@node1 soft] # rpm-ivh mysql-community-server-5.7.11-1.el5.i686.rpm
Warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Error: Failed dependencies:
Mysql-community-client = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-1.el5.i686
Mysql-community-common = 5.7.11-1.el5 is needed by mysql-community-server-5.7.11-
1.el5.i686
[root@node1 soft] # rpm-ivh mysql-community-server-5.7.11-1.el5.i686.rpm-force-nodeps
Warning: mysql-community-server-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... # [100%]
1:mysql-community-server # # [100%]
[root@node1 soft] #
[root@node1 soft] #
-- mysql automatically adds mysql users
[root@node1 soft] # id mysql
Uid=27 (mysql) gid=27 (mysql) groups=27 (mysql)
[root@node1 soft] # ls-l
Total 1201144
-rw-r--r-- 1 7155 wheel 40516 Feb 2 17:27 mysql-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 root root 614359040 Feb 18 12:02 mysql-5.7.11-1.el5.i686.rpm-bundle.tar
-rw-r--r-- 1 7155 wheel 32644512 Feb 2 17:31 mysql-community-client-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 825859 Feb 2 17:31 mysql-community-common-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 5402990 Feb 2 17:31 mysql-community-devel-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 53512687 Feb 2 17:31 mysql-community-embedded-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 168617172 Feb 2 17:31 mysql-community-embedded-devel-5.7.11-
1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2968131 Feb 2 17:32 mysql-community-libs-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 2172050 Feb 217: 32 mysql-community-libs-compat-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 209431525 Feb 2 17:33 mysql-community-server-5.7.11-1.el5.i686.rpm
-rw-r--r-- 1 7155 wheel 138730825 Feb 2 17:34 mysql-community-test-5.7.11-1.el5.i686.rpm
Third, install msql client
[root@node1 soft] # rpm-ivh mysql-community-client-5.7.11-1.el5.i686.rpm
Warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Error: Failed dependencies:
Mysql-community-libs = 5.7.11-1.el5 is needed by mysql-community-client-5.7.11-1.el5.i686
[root@node1 soft] # rpm-ivh mysql-community-client-5.7.11-1.el5.i686.rpm-force-nodeps
Warning: mysql-community-client-5.7.11-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID
5072e1f5
Preparing... # [100%]
1:mysql-community-client # # [100%]
[root@node1 soft] #
IV. Stop mysql
[root@node1 soft] # mysql
ERROR 1045 (28000): Unknown error 1045
[root@node1 soft] # / etc/rc.d/init.d/mysqld stop
Stopping mysqld: [OK]
[root@node1 soft] # netstat-anp | grep 3306
Use mysql to log in securely and change the password of root account
[root@node1] # mysqld_safe-- skip--tables &
[1] 5379
[root@node1 ~] # Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep-- help' for more information.
Grep: write error: Broken pipe
2016-02-29T19:40:08.792329Z mysqld_safe Logging to'/ var/log/mysqld.log'.
2016-02-29T19:40:08.861817Z mysqld_safe A mysqld process already exists
[1] + Exit 1 mysqld_safe-- skip--tables
[root@node1 ~] #
/ var/lib/mysql
[root@node1 ~] # mysql-u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 2
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > select rurrent_user
ERROR 1054 (42S22): Unknown error 1054
Mysql >
Mysql > use mysql
Database changed
Mysql >
Mysql >
Mysql > update mysql.user set authentication_string=password ('root') where user='root'
Query OK, 0 rows affected, 1 warning (0.00 sec)
Mysql > FLUSH PRIVILEGES
Query OK, 0 rows affected (0.00 sec)
Mysql > quit
Bye
[root@node1 ~] # / etc/init.d/mysql restart
-bash: / etc/init.d/mysql: No such file or directory
[root@node1 ~] # / etc/rc.d/init.d/mysqld start
Starting mysqld: [OK]
[root@node1 ~] #
Log in and use the command to report an error. You need to close validate_password = OFF.
[root@node1] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 9
Server version: 5.7.11
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > create database test
ERROR 1820 (HY000): Unknown error 1820
Mysql >
[root@node1 etc] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 8
Server version: 5.7.11
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql >
Mysql >
Mysql >
Mysql > use mysql
ERROR 1820 (HY000): Unknown error 1820
Mysql > update mysql.user set authentication_string=password ('root') where user='root'
ERROR 1820 (HY000): Unknown error 1820
Mysql >
Mysql >
Mysql >
Mysql > use testdb
ERROR 1820 (HY000): Unknown error 1820
Mysql > conn testdb
-> ^ C
-- modify parameters
[root@node1 etc] # vi / etc/my.cnf
Validate_password = OFF
-from its mysql
[root@node1 ~] # / etc/rc.d/init.d/mysqld restart
Stopping mysqld: [OK]
Starting mysqld: [OK]
[root@node1 ~] #
Mysql > use mysql
ERROR 1820 (HY000): Unknown error 1820
Mysql >
Mysql >
Mysql >
Mysql > use testdb
ERROR 1820 (HY000): Unknown error 1820
Mysql > select host,user,password from user
ERROR 1046 (3D000):
Mysql >
Mysql >
Note that the account password needs to be re-set, and a simple password can be used
SET PASSWORD ='* 0D3CED9BEC10A777AEC23CCC353A8C08A633045E'
Mysql > use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > use testdb
Database changed
Mysql >
-use the new password to log in to the database
[root@node1 etc] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 7
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql >
Mysql > uninstall plugin validate_password
Query OK, 0 rows affected (0.01 sec)
Mysql > SET PASSWORD = '1234'
Query OK, 0 rows affected (0.01 sec)
Mysql > quit
Bye
-log in to the database again and use it normally
[root@node1 etc] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 11
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql >
Mysql >
Mysql >
Mysql > use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql >
Mysql >