Mariadb的安装与配置mysql
Mariadb 10.0.14 Stablesql
/xwtec/mysql/数据库
https://downloads.mariadb.org/bash
切换到root用户进行以下安装:socket
# 添加mysql用户
groupadd mysql
useradd -g mysql mysql
# 安装路径设置为/usr/local
cd /usr/local
tar -zxvpf /path-to/mariadb-VERSION-OS.tar.gz
# 添加mysql软连接
ln -s mariadb-VERSION-OS mysql
# 安装mariadb
cd mysql
./scripts/mysql_install_db --user=mysql
# 更改文件属性
chown -R root .
chown -R mysql data
执行完上述步骤后,安装完毕。sqlserver
./bin/mysqld_safe --user=mysql &测试
修改 .bash_profile 或者 .bashrc 文件,添加环境变量以下:spa
export PATH=$PATH:/usr/local/mysql/bin/code
测试是否可以链接成功:orm
mysql –u root
# 复制mysql服务文件
cd /usr/local/mariadb-version/support-files/
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
# 设置开机启动(基于RPM的系统)
chkconfig --add mysql
chkconfig --level 345 mysql on
Mariadb的启动时读取配置文件my.cnf,默认的读取优先级以下:
1 /etc/my.cnf
2 /etc/mysql/my.cnf
3 my.cnf in the DEFAULT_SYSCONFDIR specified during the compilation
4 my.cnf in the path, specified in the environment variable MYSQL_HOME (if any)
5 the file specified in --defaults-extra-file (if any)
6 user-home-dir/.my.cnf
选择使用/etc/my.cnf做为配置文件,对其进行相关修改。
首先,添加数据库数据文件存放的文件夹/xwtec/mysql
cp -a /var/lib/mysql /xwtec/mysql
而后修改/etc/my.cnf,配置datadir以下
# datadir=/var/lib/mysql
datadir=/xwtec/mysql
修改root密码:
mysqladmin -u root password
问题描述:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")
解决方案:
检查my.cnf,发现socket=/var/lib/mysql/mysql.sock,因而添加软连接
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
问题描述:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13 "Permission denied")
解决方案:
添加mysql.sock所在目录的访问和读取权限:
chmod +rx /var/lib/mysql/
安装
开机启动
配置
mysql服务
mysqladmin设置
https://mariadb.com/kb/en/mariadb/documentation/clients-and-utilities/mysqladmin/