接上篇:http://wskfnso.blog.51cto.com/4025557/1761877
1:安装mariadb,获取源程序、解压、创建软连接
[root@master1 ~]# tar xf mariadb-10.0.24-linux-x86_64.tar.gz -C /usr/local/
[root@master1 ~]# cd /usr/local/
[root@master1 local]# ln -sv mariadb-10.0.24-linux-x86_64 mysql
`mysql‘ -> `mariadb-10.0.24-linux-x86_64‘
2:创建mysql系统用户和组
[root@master1 local]# groupadd -r mysql
[root@master1 local]# useradd -r -g mysql mysql -s /sbin/nologin
3:建立数据目录 存放数据,并把数据目录改为mysql用户和组
[root@master1 local]# mkdir -pv /mydata/data
[root@master1 local]# chown -R mysql.mysql /mydata/data/
4:安装数据库
[root@master1 mysql]# scripts/mysql_install_db --datadir=/mydata/data/ --user=mysql --basedir=/usr/local/mysql/
5:为mysql 提供配置文件,并修改如下
[root@master1 mysql]# cp support-files/my-large.cnf /etc/my.cnf
thread_concurrency = 2 //改成cpu的两倍
basedir = /usr/local/mysql //数据库安装目录
datadir = /mydata/data //数据目录
innodb_file_per_table = on //打开innodb引擎
skip_name_resolve = on //跳过DNS解析
6:提供启动脚本,并使其开机自启动
[root@master1 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@master1 mysql]# chkconfig --add mysqld
[root@master1 mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7:启动mysql
[root@master1 mysql]# service mysqld start
8:修改头文件和库文件
(1):输出mysql的头文件至系统头文件路径/usr/include:
# ln -sv /usr/local/mysql/include /usr/include/mysql
(2):输出mysql的库文件给系统库查找路径:
# echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
而后让系统重新载入系统库:
# ldconfig
# ldconfig -p | grep ‘mysql‘
(3):修改PATH环境变量,让系统可以直接使用mysql的相关命令
在/etc/profile.d/目录下建立mysql.sh文件! 写入如下内容:
export PATH=/usr/local/mysql/bin:$PATH
# source mysql.sh
# touch /etc/profile.d/mysql.sh
# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
# source mysql.sh
9:删除密码用户:
mysql> drop user ‘‘@‘localhost‘;
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ‘‘@‘localhost.localdomain‘;
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ‘root‘@‘localhost.localdomain‘;
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ‘root‘@‘::1‘;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for ‘root‘@‘localhost‘=password(‘123456‘);
Query OK, 0 rows affected (0.00 sec)
mysql> set password for ‘root‘@‘127.0.0.1‘=password(‘123456‘);
Query OK, 0 rows affected (0.00 sec)
本文出自 “centos6 运维学习” 博客,请务必保留此出处http://wskfnso.blog.51cto.com/4025557/1761890
原文地址:http://wskfnso.blog.51cto.com/4025557/1761890