MySQL5.6操作小结
程序员文章站
2022-05-26 23:43:51
...
安装
安装MySQL5.6通过安装一个绑定的percona包来实现,总共分为三步:
sudo yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
sudo yum install -y Percona-Server-server-56.x86_64
启动mysql服务:sudo mysqld start
登陆root用户
在默认初始化下,root用户是没有密码的,因此直接通过mysql -uroot -p
来登陆,要输入密码时直接回车。
修改root用户密码
通过命令mysqladmin -u root -p password
来键入原密码以及新密码两次。
新增数据库账户
root用户的mysql命令行 CREATE USER 'kpdbuser'@'localhost' IDENTIFIED BY '123456';
创建数据库kpdb
root用户的mysql命令行 CREATE DATABASE
kpdb/*!40100 DEFAULT CHARACTER SET utf8mb4 */;
查看mysql数据库中的用户
mysql> select user,host,password from mysql.user;
+----------+------------------------------+-------------------------------------------+
| user | host | password |
+----------+------------------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ip-172-31-48-15.ec2.internal | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | ip-172-31-48-15.ec2.internal | |
| kpdbuser | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+----------+------------------------------+-------------------------------------------+
7 rows in set (0.00 sec)
给数据库kpdbuser账户赋予访问权限
GRANT ALL ON *.* TO 'kpdbuser'@'%';
刷新权限
flush privileges
卸载MySQL5.6
sudo yum remove percona-release-0.1-3.noarch
sudo yum remove Percona-Server-server-56.x86_64
sudo yum remove mysql mysql-server mysql-libs mysql-server
find / -name mysql
将找到的相关文件夹delete掉,特别是lib包下的东西 rpm -qa|grep mysql
查询出来的东西yum remove掉
在进程中查看mysql相关的程序
rpm -qa | grep mysql