时间:2021-07-01 10:21:17 帮助过:14人阅读
find / -name mysql
|
假设查找到的路径为/usr/local/mysql/bin/mysql,可以使用下面的命令设置一个链接:
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
|
然后就可以使用mysql命令了。
利用初始化密码q<.yhitwgg!V登录mysql 操作如下图:
显示登录成功,可以执行mysql命令操作了!
未配置的情况下每次登录需要进入bin目录下操作:
7、 复制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
此处特别说明 如果出现 下面这种错误
找一下my-default.cnf 文件的位置 [root@localhost ~]# find / -name my-default.cnf 比如在(/usr/local/mysql/support-files/my-default.cnf)位置 作如下操作: [root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf |
8. 将mysqld服务加入开机自启动项。
*首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通过chkconfig命令将mysqld服务加入到自启动服务项中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
9. 重启系统,mysqld就会自动启动了。
*检查是否启动
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新启动,那可以直接手动启动。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
10 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql -uroot -p
password: Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type ‘help;‘ or ‘\h‘ forhelp. Type ‘\c‘ to clear the current input statement.
mysql> quit
Bye
*此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令:
这样就可以在shell中直接输入mysql命令来启动客户端程序了
[root@localhost mysql]#mysql -uroot -p
password: Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ forhelp. Type ‘\c‘ to clear the current input statement.
mysql>
11、改mysql的root密码,新密码在此为‘123456‘
mysql> set password=password(‘123456‘);
Query OK, 0 rows affected, 1 warning (0.00 sec)
12、设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。
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> select Host,User from user;
+-----------+-----------+
| Host | User |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
| localhost | root |
+-----------+-----------+
3 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO root@‘%‘ identified by ‘000000‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
授权语句最后的‘000000’是mysql数据库root用户的新密码。
13、非必要的步骤,如果远程连不上,估计是防火墙的问题,关闭试试:
[root@localhost mysql]# service iptables stop
setenforce 0iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@localhost mysql]# setenforce 0
setenforce: SELinux is disabl
Linux下MySQL安装
标签:overflow i686 步骤 启动服务 static input 定义 root .com