Linux CenterOS安装mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

1.准备安装包,放到 /usr/local/

百度云盘分享:mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz 链接:http://pan.baidu.com/s/1i3pWxKx 密码:t51u

[root@cnpc02 ~]# cd/usr/local/

1.1解压安装包

[root@cnpc02 local]#tar zxvf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz


重命名

[root@cnpc02 local]#mv mysql-5.6.12-linux-glibc2.5-x86_64 mysql

1.2 安装 辅助软件  yum -y install perl perl-devel

 

2.添加用户

[root@cnpc02 local]#groupadd mysql

[root@cnpc02 local]#useradd -r -g mysql mysql

3.修改目录权限

[root@cnpc02 local]#chown -R mysql.mysql /usr/local/mysql

4.初始化数据库

[root@cnpc02scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

5.注册服务

[root@cnpc02scripts]# cp /usr/local/mysql//support-files/mysql.server/etc/rc.d/init.d/mysql

[root@cnpc02scripts]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? Y  (最好配置为默认配置)

[root@cnpc02scripts]# chkconfig --add mysql 

[root@cnpc02scripts]# chkconfig mysql on

6.启动服务

[root@cnpc02scripts]# service mysql start

Starting MySQL. SUCCESS!(初次启动完成)

7.添加环境变量,可以略过。当然这样做会更方便报告mysql相关命令,也可以不添加,但每次执行命令要切换到/usr/local/mysql/bin目录或者加上绝对路径执行命令,个人觉得比较费事……

[root@cnpc02 mysql]#vi /etc/profile

exportMYSQL_HOME=/usr/local/mysql

exportPATH=$PATH:$MYSQL_HOME/bin

[root@cnpc02 mysql]#source /etc/profile

8.修改管理员密码,默认为空,所以最好修改,格式如下

[root@cnpc02 bin]#mysqladmin -u root password 'new-password'

[root@cnpc02 bin]#/usr/local/mysql/bin/mysqladmin -u root password 'new-password'(没有添加环境变量使用)

9.默认安装完成,如果考虑到安全问题,需要安全安装执行命令/usr/local/mysql/bin/mysql_secure_installation,按照提示一步步往下走,关键位置我都做了注释。

 

[root@cnpc02 bin]#/usr/local/mysql/bin/mysql_secure_installation

 

 

 

NOTE: RUNNING ALLPARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log intoMySQL to secure it, we'll need the current

password for theroot user.  If you've just installedMySQL, and

you haven't set theroot password yet, the password will be blank,

so you should justpress enter here.

 

Enter currentpassword for root (enter for none):

ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES)

Enter currentpassword for root (enter for none):

OK, successfullyused password, moving on...

 

Setting the rootpassword ensures that nobody can log into the MySQL

root user withoutthe proper authorisation.

 

You already have a root passwordset, so you can safely answer 'n'.

 

Change the root password?[Y/n] n(如果你已经修改了root密码就输入n

 ... skipping.

 

By default, a MySQLinstallation has an anonymous user, allowing anyone

to log into MySQLwithout having to have a user account created for

them.  This is intended only for testing, and tomake the installation

go a bitsmoother.  You should remove them beforemoving into a

productionenvironment.

 

Remove anonymous users?[Y/n] y(移除其它匿名用户,最好移除)

 ... Success!

 

Normally, rootshould only be allowed to connect from 'localhost'.  This

ensures that someonecannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] y(是否允许远程连接,根据需要选择)

 ... Success!

 

By default, MySQLcomes with a database named 'test' that anyone can

access.  This is also intended only for testing, andshould be removed

before moving into aproduction environment.

 

Remove test database andaccess to it? [Y/n] n(是否需要移除mysql自带的test库,随意。。)

 ... skipping.

 

Reloading theprivilege tables will ensure that all changes made so far

will take effectimmediately.

 

Reload privilege tables now?[Y/n] y(上面已做了修改是否重新加载权限表,当然y)

 ... Success!

 

 

 

 

All done!  If you've completed all of the above steps,your MySQL

installation shouldnow be secure.

 

Thanks for using MySQL!(OK初步完成,打开试试吧!)

 

 

Cleaning up...

 

10.连接mysql

[root@cnpc02 bin]#mysql -u root -p

Enter password:

Welcome to the MySQLmonitor.  Commands end with ; or \g.

Your MySQLconnection id is 10

Server version:5.6.12 MySQL Community Server (GPL)

 

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

 

Oracle is aregistered trademark of Oracle Corporation and/or its

affiliates. Othernames may be trademarks of their respective

owners.

 

Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.

 

mysql> show databases;(查看所有数据库)

+--------------------+

| Database           |

+--------------------+

| information_schema|

| mysql              |

| performance_schema|

| test               |

+--------------------+

4 rows in set (0.05sec)

 

mysql>

到此大功告成!

©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值