建組、建用戶:
[root@dbking mysql]# groupadd mysql
[root@dbking mysql]# useradd -g mysql mysql
解壓安裝程序:
[root@dbking mysql]# tar -zxvf mysql.tar.gz
[root@dbking mysql]# mv /rpm/mysql /usr/local/mysql
初始化:
[root@dbking mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
配置文件:
[root@dbking mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
log_error=mysql.err
修改目錄權限:
[root@dbking mysql]# chown -R mysql:mysql /usr/local/mysql/
修改環(huán)境變量:
export PATH=/usr/local/mysql/bin:$PATH
啟動數(shù)據(jù)庫:
[mysql@dbking ~]$ /usr/local/mysql/bin/mysqld --user=mysql &
或者
[mysql@dbking ~]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
設置mysql開機自動啟動:
[root@dbking mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@dbking mysql]# chown -R root:root /etc/rc.d/init.d/mysqld
[root@dbking mysql]# chmod 755 /etc/rc.d/init.d/mysqld
[root@dbking mysql]# chkconfig --add mysqld
[root@dbking mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@dbking mysql]# service mysqld status
ERROR! MySQL is not running
mysql的root用戶授權:
mysql> grant all privileges on *.* to 'root'@'%' identified by 'oracle';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'%'=password('oracle');
Query OK, 0 rows affected (0.00 sec)
聯(lián)系客服