redhat8 mysql安装具体过程
系统开启自启动
#cd /etc/rc.d
#vi rc.local
mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
安装顺序
rpm -ivh mysql-3.23.41-1.i386.rpm
rpm -ivh mysql-devel-3.23.41-1.i386.rpm
rpm -ivh mysql-server-3.23.41-1.i386.rpm
安装测试
[root@localhost perl]# mysql
mysql>mysql成功安装并启动
netstat -nat 查看服务器3306端口是否运行。
因为缺省情况下mysql的root用户没有口令,使用下列
[root@localhost perl]# mysqladmin -u root password 747858969;设置密码
也可以登陆数据库,usr mysql直接到mysql 数库识
show databases;
use mysql 表user中直接在
update user set Password=PASSWORD(‘123456’) where user=’root’;
[root@localhost perl]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
[root@localhost etc]# mysql -u root -p
Enter password:****
mysql>
四、修改登录密码
/usr/bin/mysqladmin -u root password 'new-password'
五、启动与停止
(1)、启动
[root@localhost init.d]# /etc/init.d/mysql start
(2)、停止
/usr/bin/mysqladmin -u root -p shutdown
(3)、自动启动
/sbin/chkconfig mysql on
六、开启远程连接
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
mysq ......
3. 停止mysql:mysqladmin -uroot -ppassw0rd shutdown 注意,u,p后没有空格 passw0rd为密码
4. 设置mysql自启动:把启动命令加入/etc/rc.local文件中
5. 允许root远程登陆:
INSERT INTO mysql.user (Host,User,Password) VALUES('%','123456', PASSWORD('123456'));
方法有如下两个方法;A:
1)本机登陆mysql:mysql -u root -p (-p一定要有);改变数据库:use mysql;
2)从所有主机:grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;
3)从指定主机:grant all privileges on *.* to root@"192.168.11.205" identified by "passw0rd" with grant option; flush privileges;
4) 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
B:
2)开启远程接入。登录到数据库,对mysql.user进行操作
表Mysql.user记录了不同用户不同主机不同的权限。可通过命令查看:
Select * from mysql.user ;
插入新用户root,其ip地址为%,指示任意主机:
Use mysql ;
Insert user set user = ‘root’ ,password = ‘123456’ ,host = ‘%’ ;
给root@’%’用户分配所有的权限:
Grant all privileges on *.* to root@’%’ identified by ‘123456’
刷新权限列表
Flush privileges