一、下载marriadb及依赖包
方法1、yum install --downloadonly --downloaddir=. mariadb mariadb-server
方法2、yum install mariad-version,带上指定版本。感觉后面一窜版本挺难找的
yum install -y mariadb-5.5.64-1.el7_5.x86_64
yum install -y mariadb-server-5.5.64-1.el7_5.x86_64
方法3、配置 mariadb 的 yum 源 (未验证)
二、安装
rpm -ivh * --nodeps --force
三、启动
systemctl start mariadb #启动MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb #设置开机启动
四、初始化数据库
mysql_secure_installation
root@hadoop001 ~]# mysql_secure_installation
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.
You already have a root password set, so you can safely answer 'n'.
#修改root密码,输入y
Change the 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.
#删除匿名用户
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.
#不允许root用户远程登录
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.
#删除test数据库
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!
注意下:Disallow root login remotely? [Y/n] n
... skipping.
设置不起做用,root 用户 不允许 远程登陆。
五、错误
1、输入 mysql 报错 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决:mysql -p123456
2、Row size too large (> 8126)
解决方案:
vim /etc/my.cnf
[mysqld]
下面加上
innodb_strict_mode = 0
3、查询表不区分大小写
vim /etc/my.cnf
lower_case_table_names = 1
完美解决
可参考官方文档
https://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html#sysvar_innodb_strict_mode
https://blog.csdn.net/sinat_34892023/article/details/102555553