1.从mirror 163 上获取 mysql tar包
2.
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
启动命令有两个
shell> bin/mysqld_safe --user=mysql &
或者
./support-files/mysql.server start --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
3.设置密码
./bin/mysqladmin -u root password '123456'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
修改完密码,重启
/support-files/mysql.server restart --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
4.密码测试
mysql -uroot 不加密码无法登录
mysql -uroot -p123456
[root@localhost ~]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 6.0.11-alpha MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
========================
开发外部访问权限
mysql -u root -p123456
mysql>use mysql;
mysql> select Host, User,Password from user;
mysql> update user set host = '%' where user ='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql>
mysql> select Host, User,Password from user;
+-----------------------+------+-------------------------------------------+
| Host | User | Password |
+-----------------------+------+-------------------------------------------+
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost.localdomain | root | |
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
修改完后重启mysql
./support-files/mysql.server restart --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
=====
1.修改文件
support-files/mysql.server , 文件内添加下列内容
--basedir=/usr/local/mysql/
--datadir=/usr/local/mysql/data/
--user=mysql
2./etc/systemd/system 增加mysql.service
内容:
[Unit]
Description=mysql
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
#ExecReload=/usr/local/mysql/support-files/mysql.server restart
#ExecStop=/usr/local/mysql/support-files/mysql.server stop
#PrivateTmp=true
[Install]
WantedBy=multi-user.target
shiy使用 service mysql.service start 就可以了