安裝mysql
# 添加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
測試可否啓動:sql
./bin/mysqld_safe --user=mysql &
添加環境變量到 .bash_profile 或者 .bashrc,便於mysql的管理的鏈接。數據庫
export PATH=$PATH:/usr/local/mysql/bin/
設置開機啓動bash
cd /usr/local/mariadb-version/support-files/ cp mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql
On RPM-based distributions (like Fedora and CentOS), you use chkconfig:socket
chkconfig --add mysql chkconfig --level 345 mysql on
配置測試
修改數據庫數據位置datadirspa
cp -a /var/lib/mysql /xwtec/mysql
修改/etc/my.cnfcode
# datadir=/var/lib/mysql datadir=/xwtec/mysql
若是遇到server
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 "No such file or directory")ip
則添加軟連接:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
修改root密碼:
mysqladmin -u root password