linux下安裝mysql服務,並且本地進行連接mysql。 ...
yum install -y perl-Module-Install.noarch
yum -y install perl perl-devel
#命令下載mysql
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
#複製解壓後的mysql目錄
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
#添加用戶組
groupadd mysql
#添加用戶mysql 到用戶組mysql
useradd -g mysql mysql
cd /usr/local/mysql/
mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
#修改啟動腳本
vi /etc/init.d/mysqld
#修改項:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
#刪除/etc/my.cnf文件
rm -f /etc/my.cnf
#啟動服務
service mysqld start
#更換密碼
./bin/mysqladmin -u root -h localhost.localdomain password 'root'
#登錄mysql
./bin/mysql -h127.0.0.1 -uroot -proot
#登錄之後將其他用戶的密碼也可改為root
update mysql.user set password=password('root') where user='root';
flush privileges;
#遠程訪問
GRANT ALL PRIVILEGES ON *.* to 'root'@'192.168.1.10' identified by '123456';
flush privileges;
#加入環境變數,
export PATH=$PATH:/usr/local/mysql//bin
source /etc/profile
#測試,任意目錄下執行進行訪問資料庫服務
mysql -uroot -proot