linux下mysql的卸载、安装全过程
程序员文章站
2022-06-23 20:40:00
...
1、查找以前是否装有mysql
可以看到mysql的两个包:
mysqlclient10-3.23.58-4.RHEL4.1
删除命令:rpm -e --nodeps 包名
3、删除老版本mysql的开发头文件和库
rm -fr /usr/include/mysql
rm -f /etc/my.cnf
安装mysql
MySQL-client-5.1.20-0.glibc23.i386.rpm
1、安装服务端:
安装成功会出现....
Preparing... ########################################### [100%]
080220 13:58:27 [Note] Plugin 'InnoDB' disabled by command line option
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
/usr/bin/mysqladmin -u root password 'new-password'
See the manual for more instructions.
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at http://shop.mysql.com
2、安装客户端
成功表现:
warning: MySQL-client-5.1.20-0.glibc23.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
1:MySQL-client ########################################### [100%]
/usr/bin/mysqladmin -u root password 'new-password'
登陆MySql的命令是mysql,mysql 的使用语法如下:
mysql -u root -p
其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。
4.修改字符集
通过MySQL命令行修改:
mysql> set character_set_client=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_connection=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_results=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_system=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_connection=utf8_general_ci ;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_database=utf8_general_ci ;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_server=utf8_general_ci;
Query OK, 0 rows affected (0.01 sec)
查看:
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.03 sec)
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.04 sec)
修改数据库的字符集
mysql>use mydb
mysql>alter database mydb character set utf-8;
创建数据库指定数据库的字符集
mysql>create database mydb character set utf-8;
以下可以不必需要补:
以MySQL-server-4.0.14-0.i386.rpm为例,放在/data目录下
rpm -ivh MySQL-server-4.0.14-0.i386.rpm
拷贝一个示例配置文件作为mysql的配置文件:
rpm包安装完后自动将mysql安装成系统服务,所以可以使用下面命令启动、停止mysql
/etc/init.d/mysql start 或 service mysql start
/etc/init.d/mysql stop 或 service mysql stop
安装mysql客户端
mysql安装好后目录结构如下:
服务器程序/usr/sbin/mysqld
默认情况下mysql将错误日志文件、二进制日志文件及进程文件写在/var/lib/mysql目录中,如localhost.err、localhost.pid、localhost-bin.001等
如将日志文件写在/var/log目录中,可以在my.cnf文件中加入下面两行:
err-log = /var/log/mysqld.log
有个实用程序/usr/bin/mysql_install_db,该程序可以用来初始化
mysql数据库,即创建/var/log/mysql目录,及创建mysql数据库(mysql授权表等信息)及test数据库(空库),如果不小心删
除了/var/log/mysql目录可以通过该程序来初始化.
rpm -qa|grep -i mysql
卸载后/var/lib/mysql中的数据及/etc/my.cnf不会删除,如果确定没用后就手工删除
rm -rf /var/lib/mysql
通过MySQL-Front或mysql administrator连接mysql的时候发生的这个错误
mysql -h172.21.5.29 -uadmin -padmin 即可了
//172.21.5.29就是MySQL Server的IP地址,admin admin就是刚才在 172.21.5.29上设置的远程访问帐户
远程访问:
mysql> use mysql;
mysql> GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
原来 上面的 % 竟然不包括localhost 所以你还必须加上这样的 命令
mysql>GRANT ALL ON *.* TO admin@'localhost' IDENTIFIED BY 'admin' WITH GRANT OPTION;
可以看到mysql的两个包:
mysqlclient10-3.23.58-4.RHEL4.1
删除命令:rpm -e --nodeps 包名
3、删除老版本mysql的开发头文件和库
rm -fr /usr/include/mysql
rm -f /etc/my.cnf
安装mysql
MySQL-client-5.1.20-0.glibc23.i386.rpm
1、安装服务端:
安装成功会出现....
Preparing... ########################################### [100%]
080220 13:58:27 [Note] Plugin 'InnoDB' disabled by command line option
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
/usr/bin/mysqladmin -u root password 'new-password'
See the manual for more instructions.
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at http://shop.mysql.com
2、安装客户端
成功表现:
warning: MySQL-client-5.1.20-0.glibc23.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
1:MySQL-client ########################################### [100%]
/usr/bin/mysqladmin -u root password 'new-password'
登陆MySql的命令是mysql,mysql 的使用语法如下:
mysql -u root -p
其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。
4.修改字符集
通过MySQL命令行修改:
mysql> set character_set_client=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_connection=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_results=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_system=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_connection=utf8_general_ci ;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_database=utf8_general_ci ;
Query OK, 0 rows affected (0.01 sec)
mysql> set collation_server=utf8_general_ci;
Query OK, 0 rows affected (0.01 sec)
查看:
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.03 sec)
mysql> show variables like 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.04 sec)
修改数据库的字符集
mysql>use mydb
mysql>alter database mydb character set utf-8;
创建数据库指定数据库的字符集
mysql>create database mydb character set utf-8;
以下可以不必需要补:
以MySQL-server-4.0.14-0.i386.rpm为例,放在/data目录下
rpm -ivh MySQL-server-4.0.14-0.i386.rpm
拷贝一个示例配置文件作为mysql的配置文件:
rpm包安装完后自动将mysql安装成系统服务,所以可以使用下面命令启动、停止mysql
/etc/init.d/mysql start 或 service mysql start
/etc/init.d/mysql stop 或 service mysql stop
安装mysql客户端
mysql安装好后目录结构如下:
服务器程序/usr/sbin/mysqld
默认情况下mysql将错误日志文件、二进制日志文件及进程文件写在/var/lib/mysql目录中,如localhost.err、localhost.pid、localhost-bin.001等
如将日志文件写在/var/log目录中,可以在my.cnf文件中加入下面两行:
err-log = /var/log/mysqld.log
有个实用程序/usr/bin/mysql_install_db,该程序可以用来初始化
mysql数据库,即创建/var/log/mysql目录,及创建mysql数据库(mysql授权表等信息)及test数据库(空库),如果不小心删
除了/var/log/mysql目录可以通过该程序来初始化.
rpm -qa|grep -i mysql
卸载后/var/lib/mysql中的数据及/etc/my.cnf不会删除,如果确定没用后就手工删除
rm -rf /var/lib/mysql
通过MySQL-Front或mysql administrator连接mysql的时候发生的这个错误
mysql -h172.21.5.29 -uadmin -padmin 即可了
//172.21.5.29就是MySQL Server的IP地址,admin admin就是刚才在 172.21.5.29上设置的远程访问帐户
远程访问:
mysql> use mysql;
mysql> GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
原来 上面的 % 竟然不包括localhost 所以你还必须加上这样的 命令
mysql>GRANT ALL ON *.* TO admin@'localhost' IDENTIFIED BY 'admin' WITH GRANT OPTION;
上一篇: nginx的会话保持
下一篇: hive-数据倾斜解决详解