直接执行-A也是可以的,进入mysql系统数据库
分类:巴黎人-数据库

本机登入数据库,直接实施-A也是足以的。

default-character-set=utf8

创立机关备份脚本
在这里间,为了使数据库教程备份和还原的符合大家的骨子里需要,用一段切合必要的Shell脚本来实现存套备份进度的自动化。
[[email protected] ~]# vi mysql教程-backup.sh  ← 创建数据库自动备份脚本,如下:

Mysql5.6记不清root密码修改root密码的秘诀,mysql5.6root

mysql5.6记不清数据库的root密码:

[[email protected] ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

翻开当前安装的mysql版本:

[email protected] ~]# rpm -qa | grep MySQL
MySQL-server-5.6.15-1.el6.x86_64
MySQL-client-5.6.15-1.el6.x86_64
MySQL-shared-compat-5.6.15-1.el6.x86_64
MySQL-devel-5.6.15-1.el6.x86_64
perl-DBD-MySQL-4.022-1.el6.rfx.x86_64

停止mysql服务:

[[email protected] ~]# service mysql stop
Shutting down MySQL.. SUCCESS!

进入到skip-grant-tables模式:

[[email protected] ~]# mysqld_safe --skip-grant-tables
140211 15:37:49 mysqld_safe Logging to '/var/lib/mysql/oraserver139.err'.
140211 15:37:49 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

最近就不必要密码就足以进来mysql了:

[[email protected] ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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> 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

修改root账户密码:

mysql> update user set password=password("12345") where user="root";
Query OK, 4 rows affected (0.02 sec)
Rows matched: 4 Changed: 4 Warnings: 0

刷新权限:

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

停止mysql进程:

[1]+ Stopped mysqld_safe --skip-grant-tables

启动mysql:

[[email protected] ~]# service mysql start
Starting MySQL SUCCESS!

应用刚才修改的密码步向mysql:

[[email protected] ~]# mysql -uroot -p12345
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.6.15

Copyright (c) 2000, 2013, 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> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> SET PASSWORD = PASSWORD('12345');
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

修改产生;

以上所述是作者给大家介绍的Mysql5.6遗忘root密码修改root密码的措施,希望对我们有着支持,即使大家有此外疑问请给自家留言,作者会及时过来咱们的。在这里也特别谢谢我们对帮客之家网址的协理!

mysql5.6记不清数据库的root密码: [[email protected] ~]# mysql -uroot -p Enter password: ERROR 1045 (28000):...

是因为MYSQL中数据库太大,导致读取预读时间太长,进而浮现那个提醒,要是从前都不曾会见这一个主题素材,那么发生这么些主题素材的案由想必是出于有改观数据库新闻的操作,例如drop一个一点都不小的表(几千万数码)而中途终止.

那样做的补益就是让我们大家在操作数据库时进一步方便快捷。

Database changed
mysql> update test set name='Shit,Windows';  ← 然后将test中表的值重新定义为“Shit,Windows”(原本为“Hello,CentOS”)
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

mysql(root@localhost:(none))>use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

mysql> create table test(num int, name varchar(50));  ← 在数据库中确立一个表
Query OK, 0 rows affected (0.07 sec)

shell> mysql -h hostname -u username -P port -p -A

此间也付出需求的有的个选项供大家参考。

mysql> show databases;
+---------------+
| Database |
+---------------+
| mysql |  ← 确认测验用的test数据库已空中楼阁、已被去除
+---------------+
1 row in set (0.01 sec)

Database changed
mysql> q
Bye
[root@localhost ~]# mysql -u root -p -A
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 12
Server version: 5.7.23 MySQL Community Server (GPL)

Database changed
root@localhost:test 08:23:44>exit;

mysql> select * from test;  ← 查看数据库中的内容
+------+-----------------+
| num | name |
+------+-----------------+
|1  | Hello,Centos |  ← 确认刚刚插入到表中的值的留存
+------+------------------+
1 row in set (0.01 sec)

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

复制代码 代码如下:

[1] 当数据库被删去后的借尸还魂措施
率先创造一个测验用的数据库。
[[email protected] ~]# mysql -u root -p   ← 用root登录到MySQL服务器
Enter password:  ← 输入MySQL的root客户密码
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8 to server version: 4.1.20

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

mysql> use test  ← 连接到test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

mysql> show processlist ;    (查看进程)

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

上述,我们就相当于模拟了数据库被毁掉的历程。接下来,是数据库被“破坏”后,用备份举行理并答复苏的方法。
[[email protected] ~]# /bin/cp -Wranglerf /backup/mysql/test/ /var/lib/mysql/  ← 复制备份的数据库test到对应目录
[[email protected] ~]# chown -宝马X3 mysql:mysql /var/lib/mysql/test/  ← 改换数据库test的着落为mysql
[[email protected] ~]# chmod 700 /var/lib/mysql/test/  ← 改动数据库目录属性为700
[[email protected] ~]# chmod 660 /var/lib/mysql/test/*  ← 改换数据库中数量的性质为660

去除那么些锁表的情景,作者的mysql就能够正常采访了。

复制代码 代码如下:

mysql> exit  ← 退出MySQL服务器
Bye

(eg:shell> mysql -h 127.0.0.1 -u root -P 3306 -p -A)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

mysql> use test  ← 连接到test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Enter password:

root@localhost:(none) 08:23:32>use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

# Backup with Database
for dbname in $DBLIST
do
mysqlhotcopy $dbname -u root -p $ROOTPASS $BACKDIR | logger -t mysqlhotcopy
done

mysql> use test
Database changed
mysql>

复制代码 代码如下:

mysql> use test  ← 连接到test数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

 

[mysql]
prompt=mysql(\u@\h:\d)>

mysql> select * from test;  ← 查看数据库中的内容
+------+--------------------+
| num | name  |
+------+--------------------+
| 1 | Hello,CentOS|
+------+--------------------+
1 row in set (0.01 sec)

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Database changed
mysql(root@localhost:test)>

mysql> select * from test;  ← 查看数据库中的内容
+------+---------------------+
| num | name  |
+------+---------------------+
| 1 | Hello,CentOS |  ← 确认数据表中的内容与删除前定义的“Hello,CentOS”同样!
+------+---------------------+
1 row in set (0.01 sec)

上海教室中锁表的id为16545618,则能够利用kill命令,截至它.

你也得以在在my.cnf配置文件里开展示公布局:

mysql> drop database test;  ← 删除测验用数据库test
Query OK, 0 rows affected (0.00 sec)

    登录数据库后,接纳数据库时意识以下提示,

[root@fsailing1 ~]# vim /etc/my.cnf
[root@fsailing1 ~]# service mysqld restart
停止 MySQL:                                               [确定]
启动 MySQL:                                               [确定]
[root@fsailing1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution

下一场,运行刚才营造的数据库备份脚本,备份刚刚创立的测量试验用的数据库。
[[email protected] ~]# cd ← 回到脚本所在的root客商的根目录
[[email protected] ~]# ./mysql-backup.sh  ← 运转脚本进行数据库备份

本文由巴黎人手机版发布于巴黎人-数据库,转载请注明出处:直接执行-A也是可以的,进入mysql系统数据库

上一篇:函数等基本操作巴黎人澳门官网: 下一篇:没有了
猜你喜欢
热门排行
精彩图文