`
小于Brick
  • 浏览: 89773 次
  • 性别: Icon_minigender_1
  • 来自: 新疆
社区版块
存档分类
最新评论

centos7.2 安装 mysql5.7/mariadb5.5

阅读更多

 

参考:http://www.centoscn.com/image-text/install/2014/0909/3704.html

 

https://mariadb.com/kb/en/mariadb/yum/

 

mysql 和mariadb 的关系(来源于网络):

 

MySQL之父Widenius先生离开了Sun之后,觉得依靠Sun/Oracle来发展MySQL,实在很不靠谱,于是决定另开分支,这个分支的名字叫做MariaDB。
MariaDB跟MySQL在绝大多数方面是兼容的,对于开发者来说,几乎感觉不到任何不同。目前MariaDB是发展最快的MySQL分支版本,新版本发布速度已经超过了Oracle官方的MySQL版本。

MariaDB 是一个采用Aria存储引擎的MySQL分支版本,是由原来 MySQL 的作者Michael Widenius创办的公司所开发的免费开源的数据库服务器。[1]
这个项目的更多的代码都改编于 MySQL 6.0,例如 “pool of threads”功能提供解决多数据连接问题。

所以对于大部分的MySQL用户来说,从现在主流的MySQL转到MariaDB应该是没有什么难度的

=============================这里mariadb 是mysql5.5版本==========================

mariadb 安装:

yum -y install mariadb*  

 

安装完成后: 

开机自动开启服务:

[root@localhost ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl start mariadb.service

 

 mysql 命令测试一下:
[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

MariaDB [(none)]> use test
Database changed
MariaDB [test]> show tables;
Empty set (0.00 sec)

MariaDB [test]> exit
Bye

 

使用命令mysql_secure_installation安全配置:

[root@localhost ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation:行379: find_mysql_client: 未找到命令

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, 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 MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: (密码)
Re-enter new password:(重复上面的密码) 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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.
(下面可以一路y下去了)
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] y
 ... Success!

By default, MariaDB 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
 - 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!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

以上就配置完成了!!! 

重新登录一下:

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 

 

确认一下是不是开机自启动:

 [root@localhost ~]# systemctl is-enabled mariadb
 enabled

 

 

 

数据库创建用户、授权请参考:http://youngbrick.iteye.com/blog/2335889

 

 

 

============下面通过oracle 官方yum源安装mysql5.7=======================

 

参考官方:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

参考: http://www.centoscn.com/mysql/2016/0626/7537.html

 

在这找你要的rpm版本:https://dev.mysql.com/downloads/repo/yum/

1、下载rpm

 

#wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

#rpm -ivh mysql57-community-release-el7-9.noarch.rpm
 2、安装mysql
#yum install mysql-community-server
 3、查看服务启动状态
#systemctl status mysqld
如果服务已经启动:就可以使用mysql了,默认密码是随机的
4、查看密码:
# grep 'temporary password' /var/log/mysqld.log 
[Note] A temporary password is generated for root@localhost: ,!8vdxgwZwvU
 我这里的密码是:(前面的一个空格忽略),【!8vdxgwZwvU
5、进入mysql:
#mysql -uroot -p 
6、修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
 这里修改会失败,提示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
 原因是密码策略问题,必须含有数字,小写或大写字母,特殊字符。只是为了自己测试,不想密码设置得那么复杂
7、修改密码策略:
mysql> set global validate_password_policy=0;
 
8、重复上面的修改密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
 
提示语句执行成功后,完成
 
 
备注:如果在mysql.log 中没有找到密码,那么加跳过授权表配置:# vim /etc/my.cnf
1、在[mysqld]的段中加上一句:skip-grant-tables=1
2、重启服务:systemctl restart msyqld
3、mysql -p  或  mysql -uroot    回程进入mysql
4、修改密码:
mysql> update mysql.user set authentication_string=password('123456!n') where user='root' and Host = 'localhost';
mysql> flush privileges ;
5、根据修改的帐号进入mysql
#mysql -uroot -p
6、需要alter再次修改密码,否则有问题:
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '123456!n';
mysql> flush privileges ;
最后ok
 ============================msyql版本升级==================================
https://dev.mysql.com/doc/refman/5.7/en/updating-yum-repo.html
 
 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics