redhat6.4安装MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
首先下载下面三个文件:
MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
MySQL-client-5.5.28-1.linux2.6.x86_64.rpm
MySQL-devel-5.5.28-1.linux2.6.x86_64.rpm
然后使用root账号登陆,进行安装:
1. 安装server、devel、client:1. 安装server、devel、client:
rpm -ivh --replacefiles MySQL-s*.rpm
rpm -ivh --replacefiles MySQL-d*.rpm
rpm -ivh --replacefiles MySQL-c*.rpm
[root@localhost ~]# rpm -ivh --replacefiles MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
[root@localhost ~]# rpm -ivh --replacefiles MySQL-client-5.5.28-1.linux2.6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@localhost ~]# rpm -ivh --replacefiles MySQL-devel-5.5.28-1.linux2.6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
要移除安装可以使用 rpm -e MySQL-server 、 rpm -e MySQL-devel、MySQL-client即可;
2. 初始化数据库:
/usr/bin/mysql_install_db
3. 启动mysql服务:
service mysql start
使用命令ps -ef | grep mysql 查看mysql进程:
[root@localhost ~]# ps -ef|grep mysql root 3708 3057 0 18:39 pts/1 00:00:00 grep mysql
4.第一次登陆设置root密码:
首先查看 cat /root/.mysql_secret //有时候找不到那就先不管 往下看
root@localhost ~]# cat /root/.mysql_secret
# The random password set for the root user at Fri Aug 30 15:57:18 2013 (local time): fMYcarvB 这部网上说这样反正我没成功
然后命令行:mysql -u root -p ,然后输入上面的密码即可:
[root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
设置root密码:
mysql> use mysql
Database changed
mysql> update user set password=password('root') where user='root';
Query OK, 0 rows affected (0.15 sec)
Rows matched: 5 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出,重新登陆即可使用新的密码登陆;
5. 设置远程登陆:
使用root登陆到mysql后
切换到mysql数据库
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec)
mysql> update user set host='%' where user='root'; ERROR 1046 (3D000): No database selected mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> update user set host='%' where user='root'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' mysql> select host,user from user; +-----------------------+------+ | host | user | +-----------------------+------+ | % | root | | 127.0.0.1 | root | | ::1 | root | | localhost | | | localhost.localdomain | | | localhost.localdomain | root | +-----------------------+------+ 6 rows in set (0.00 sec)
然后:
mysql> grant all privileges on *.* to 'root'@'@' with grant option; ERROR 1105 (HY000): Malformed hostname (illegal symbol: '@') mysql> grant all privileges on *.* to 'root'@'%' with grant option; Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@localhost ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
重启mysql即可远程登陆。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端