90.MySQL5.6数据库安装

本文详细介绍了如何在Linux系统上通过RPM包安装MySQL5.6.20,包括服务器的初始化、设置root密码、删除匿名用户和test数据库,以及修改字符集的过程。
摘要由CSDN通过智能技术生成

1.MySQL 5.6.20 数据库安装 

MySQL5.6只有RPM安装包 

MySQL-client-5.6.20-1.el7.x86_64.rpm
MySQL-devel-5.6.20-1.el7.x86_64.rpm
--MySQL-embedded-5.6.20-1.el7.x86_64.rpm
MySQL-server-5.6.20-1.el7.x86_64.rpm
MySQL-shared-5.6.20-1.el7.x86_64.rpm
MySQL-shared-compat-5.6.20-1.el7.x86_64.rpm
--MySQL-test-5.6.20-1.el7.x86_64.rpm


rpm -ivh MySQL-devel-5.6.20-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.20-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.20-1.el7.x86_64.rpm

安装SERVER时已经自动初始化数据库。
MySQL 的默认参数。
[root@mysql57 mysql]# cat /usr/my.cnf  |grep -v ^#|grep -v ^$
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

2.查看MYSQL密码。

[root@mysql57 ~]# cat /root/.mysql_secret 
# The random password set for the root user at Tue Nov 28 19:36:24 2023 (local time): MwuuhU1r5LinVJR3

3.启动数据库 

[root@mysql57 mysql]# service mysql start
Starting MySQL.. SUCCESS! 
[root@mysql57 mysql]# pwd
/var/lib/mysql
[root@mysql57 mysql]# ll
total 110620
-rw-rw---- 1 mysql mysql       56 Nov 28 19:41 auto.cnf
-rw-rw---- 1 mysql mysql 12582912 Nov 28 19:41 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Nov 28 19:41 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Nov 28 19:36 ib_logfile1
drwx--x--x 2 mysql mysql     4096 Nov 28 19:36 mysql
-rw-r----- 1 mysql root      2017 Nov 28 19:41 mysql57.err
-rw-rw---- 1 mysql mysql        5 Nov 28 19:41 mysql57.pid
srwxrwxrwx 1 mysql mysql        0 Nov 28 19:41 mysql.sock
drwx------ 2 mysql mysql     4096 Nov 28 19:36 performance_schema
-rw-r--r-- 1 root  root       111 Nov 28 19:36 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql      111 Nov 28 19:36 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x 2 mysql mysql        6 Nov 28 19:36 test

MySQL进程查看 
[root@mysql57 mysql]# ps -ef |grep mysql |grep -v grep 
root       3469      1  0 19:41 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/mysql57.pid
mysql      3572   3469  0 19:41 pts/1    00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/mysql57.err --pid-file=/var/lib/mysql/mysql57.pid

4.运行如下脚本

(1)修改root用户的密码
(2)删除匿名用户。
(3)删除test数据库  
[root@mysql57 ~]#  /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] Y  --修改root密码。
New password: MwuuhU1r5LinVJR3 --上面密码文件里生成的密码。
Re-enter new password: MwuuhU1r5LinVJR3
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y  --删除匿名用户。
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n   --不禁用root远程登录
 ... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y  --删除test数据库
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y    --重新加载权限表。
 ... Success!
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...

5.查看数据库 

[root@mysql57 ~]# mysql -uroot -prootroot -e "show databases;"
Warning: Using a password on the command line interface can be insecure.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
[root@mysql57 ~]# 

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.20    |
+-----------+
1 row in set (0.00 sec)

6.修改字符集。

[root@mysql57 ~]# cat /usr/my.cnf |grep -v ^$|grep -v ^#
[mysql]
default-character-set=utf8
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
server-id=7556
port=3306
user = mysql
bind_address= 0.0.0.0
character_set_server=utf8

7.总结

mysql5.6只有rpm的安装包,没有其他形式的安装包。且安装方法与后面的包有所有不同。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值