[root@hanfeng ~]# ps aux |grep mysql
root 1659 0.0 0.1 115392 1712 ? S 21:29 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/hanfeng.pid
mysql 2260 0.0 45.3 973548 458428 ? Sl 21:29 0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/hanfeng.err --pid-file=/data/mysql/hanfeng.pid
root 2386 0.0 0.0 112676 984 pts/0 R+ 22:06 0:00 grep --color=auto mysql
[root@hanfeng ~]#
/etc/init.d/mysqld start
[root@hanfeng ~]# mysql -uroot
-bash: mysql: 未找到命令
[root@hanfeng ~]# ls /usr/local/mysql/bin/mysql
/usr/local/mysql/bin/mysql
[root@hanfeng ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@hanfeng ~]#
[root@hanfeng ~]# export PATH=$PATH:/usr/local/mysql/bin/
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 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> quit
Bye
[root@hanfeng ~]#
[root@hanfeng ~]# vim /etc/profile
将内容放到配置文件的最后面,使命令永久生效
export PATH=$PATH:/usr/local/mysql/bin/
保存退出
[root@hanfeng ~]# source /etc/profile
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35 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> quit
Bye
[root@hanfeng ~]#
[root@hanfeng ~]# mysqladmin -uroot password 'hanfeng.1'
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.35 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> quit
Bye
[root@hanfeng ~]#
[root@hanfeng ~]# mysqladmin -uroot -p'hanfeng.1' password 'hanfeng'
Warning: Using a password on the command line interface can be insecure.
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -p 'hanfeng'
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@hanfeng ~]# mysql -uroot -p'hanfeng'
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 13
Server version: 5.6.35 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> quit
Bye
[root@hanfeng ~]#
[root@hanfeng ~]# vim /etc/my.cnf
在[mysqld]下面
加入一行
skip-grant
保存退出
[root@hanfeng ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 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> 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 * from user;
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+
| Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
等等等,都是乱码
mysql> select password from user where user=’root’;
ERROR 1054 (42S22): Unknown column '’root’' in 'where clause'
mysql> select password from user where user='root';
+-------------------------------------------+
| password |
+-------------------------------------------+
| *406D1994F8340A1442C5090388944CCB985BA3DE |
| |
| |
| |
+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
mysql> update user set password=password('aminglinux') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql>
mysql> quit
Bye
[root@hanfeng ~]# vim /etc/my.cnf
在[mysqld]下面删除刚添加的
删除skip-grant
保存退出
[root@hanfeng ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@hanfeng ~]#
[root@hanfeng ~]# mysql -uroot -paminglinux
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 1
Server version: 5.6.35 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> quit
Bye
[root@hanfeng ~]#