【其他】MySql数据库的安装与卸载

时间:2023-01-27 23:49:21

一、安装

1、首先下载安装包,包含服务端和客户端

2、添加用户组、用户

secondary1:~ # groupadd mysql

secondary1:~ # useradd -g mysql -d /home/mysql -s /bin/bash -m mysql

3、设置mysql用户的密码

secondary1:~ # passwd mysql

Changing password for mysql.

New Password:

Reenter New Password:

Password changed.

4、将安装包上传到mysql家目录,并执行安装

secondary1:~ # cd /home/mysql/

secondary1:/home/mysql # rz

z waiting to receive.**B0100000023be50

secondary1:/home/mysql # ll MySQL*

-rw-r--r-- 1 root root 16835057 Jun 4 09:16 MySQL-client-5.6.16-1.sles11.x86_64.rpm

-rw-r--r-- 1 root root 49883518 Jun 4 09:33 MySQL-server-5.6.16-1.sles11.x86_64.rpm

secondary1:/home/mysql # rpm -ivh MySQL-server-5.6.16-1.sles11.x86_64.rpm
secondary1:/home/mysql # rpm -ivh MySQL-client-5.6.16-1.sles11.x86_64.rpm
5、启动mysql服务端

secondary1:/home/mysql # /etc/init.d/mysql start

Starting MySQL. done

secondary1:/home/mysql #

6、设置root用户密码

mysql的默认用户root的密码保存在/root/.mysql_secret,

secondary1:/home/mysql # cat /root/.mysql_secret

The random password set for the root user at Thu Jun 4 15:32:31 2015 (local time): e3Do1iml

secondary1:/home/mysql # mysqladmin -uroot -pe3Do1iml password Atae1234

Warning: Using a password on the command line interface can be insecure.

secondary1:/home/mysql #

7、设置mysql不区分大小写

secondary1:/home/mysql # echo "lower_case_table_names=1" >> /usr/my.cnf

8、重启mysql服务端

secondary1:/home/mysql # /etc/init.d/mysql restart

Shutting down MySQL.. done

Starting MySQL. done

secondary1:/home/mysql #

9、修改mysql的连接

secondary1:/home/mysql # mysql -uroot -p'Atae1234'

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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.

mysql> update mysql.user set host = '%' where host = 'localhost';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

mysql> delete from mysql.user where host = 'secondary1';

Query OK, 1 row affected (0.02 sec)

mysql> delete from mysql.user where host = '::1';

Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql>

二、卸载

secondary1:/home/mysql # rpm -qa|grep mysql -i | xargs -i rpm -e {} --nodeps

insserv: script kdump: service boot.kdump already provided!

insserv: warning: current start runlevel(s) (3 5) of script `corosync' overwrites defaults (empty).

insserv: warning: script 'init.ohasd' missing LSB tags and overrides

insserv: Default-Start undefined, assuming default start runlevel(s) for script `init.ohasd'

mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off

secondary1:/home/mysql # rm -rf /var/lib/mysql

secondary1:/home/mysql # rm -f /usr/my.cnf

secondary1:/home/mysql # cd

secondary1:~ # userdel -rf mysql

no crontab for mysql

secondary1:~ # groupdel mysql