MySQL 5.7.28/Centos-RHEL7/ mysqldump

1.   MySQL 5.7.28  Community Server   Centos7

 

[lake@localhost opt]$ netstat  -an --tcp |grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN

[lake@localhost opt]$ systemctl status  mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/etc/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-06-11 09:42:28 CST; 1h 32min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 9030 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─9030 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

Jun 11 09:42:29 localhost.localdomain mysqld[9030]: 2020-06-11T01:42:29.194736Z 0 [Note] /usr/l...s.
Jun 11 09:42:29 localhost.localdomain mysqld[9030]: Version: '5.7.28'  socket: '/tmp/mysql.sock...L)
Jun 11 09:42:48 localhost.localdomain mysqld[9030]: 2020-06-11T01:42:48.523547Z 2 [Note] Access...S)
Jun 11 09:43:42 localhost.localdomain mysqld[9030]: 2020-06-11T01:43:42.104118Z 3 [Note] Access...S)
Jun 11 09:57:06 localhost.localdomain mysqld[9030]: 2020-06-11T01:57:06.800131Z 7 [Warning] IP ...wn
Jun 11 09:57:09 localhost.localdomain mysqld[9030]: 2020-06-11T01:57:09.490904Z 7 [Note] Aborte...s)
Jun 11 10:08:03 localhost.localdomain mysqld[9030]: 2020-06-11T02:08:03.207293Z 8 [Note] Got pa...er
Jun 11 11:13:30 localhost.localdomain mysqld[9030]: 2020-06-11T03:13:30.651913Z 9 [Note] Access...O)
Jun 11 11:13:36 localhost.localdomain mysqld[9030]: 2020-06-11T03:13:36.239369Z 10 [Note] Acces...O)
Jun 11 11:13:42 localhost.localdomain mysqld[9030]: 2020-06-11T03:13:42.416869Z 11 [Note] Acces...O)
Hint: Some lines were ellipsized, use -l to show in full.
[lake@localhost opt]$ cat /etc/my.cnf
#[mysqld]
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
## Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
## Settings user and group are ignored when systemd is used.
## If you need to run mysqld under a different user or group,
## customize your systemd unit file for mariadb according to the
## instructions in http://fedoraproject.org/wiki/Systemd
#
#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
##
## include all files from the config directory
##
#!includedir /etc/my.cnf.d

[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data_mysql
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
[lake@localhost opt]$ mysql
ERROR 1045 (28000): Access denied for user 'lake'@'localhost' (using password: NO)
[lake@localhost opt]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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> select user,authentication_string  from  user ;
+---------------+-------------------------------------------+
| user          | authentication_string                     |
+---------------+-------------------------------------------+
| root          | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root          | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+---------------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql>

################

Change root/mysql password


[lake@localhost opt]$ mysql -u root -p 

Enter password: 
mysql> use mysql //選擇mysql數據庫
mysql> update user set Password = password('123456') where User = 'root'; 
//更新root密碼,password()是一個將密碼進行加密的方法,'123456'是更改後的root密碼。

mysql> quit
Bye 

 

2. mysqldump  database/gogs 

 

[git@DESKTOP-P55Q2H7 ~]$ mysqldump  -u  root  -p gogs >gogs.dump.sql
Enter password:
[git@DESKTOP-P55Q2H7 ~]$ ls  -l
total 41308
drwxr-xr-x. 8 git  git      4096 Jun 15 11:30 gogs
-rw-rw-r--. 1 lake lake 25690601 Jun 15 10:36 gogs_0.11.91_linux_amd64.tar.gz
-rw-rw-r--. 1 git  git  16596632 Jun 15 13:55 gogs.dump.sql
drwxrwxr-x. 4 git  git      4096 Jun 15 11:30 gogs-repositories
[git@DESKTOP-P55Q2H7 ~]$
 

 

3.   Import mysqldump file (DB must exit) 

[git@DESKTOP-P55Q2H7 ~]$ mysql  -u root -p   < ./gogs.dump.sql
Enter password:
ERROR 1046 (3D000) at line 22: No database selected
[git@DESKTOP-P55Q2H7 ~]$ mysql  -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 706
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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 gogs;
ERROR 1049 (42000): Unknown database 'gogs'
mysql> create database  gogs;
Query OK, 1 row affected (0.00 sec)

mysql> source  /home/git/gogs.dump.sql
  
mysql> use gogs
Database changed
mysql> source  /home/git/gogs.dump.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
..............

 

4.   Import sql/Example from gogs initialized mysql DB 

[git@DESKTOP-P55Q2H7 gogs]$ mysql -u root   -p   <scripts/mysql.sql
Enter password:123
[git@DESKTOP-P55Q2H7 gogs]$

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章