Linux中安装卸载Mysql

1. yum install mysql-server mysql-devel mysql                      注意:(mysql-server中的mysql不是大写csdn的BUG)

2. 启动mysqld服务, service mysqld start

3.设置mysql帐号
    mysql安装后默认生成两个帐号:一个是root,未设置密码,可以从本机登录到mysql;另一个是匿名帐号,无帐号名、无密码,可以从本机登录,未提供用户名的连接都将假定为此帐号。


    这样的设置存在着安全隐患,按下面的步骤进行更改。
           以root帐号连接到mysql服务器:
           mysql -u root
           如果提示找不到mysql文件,请尝试使用绝对路径,如本文示例为:
           /usr/local/mysql/bin/mysql -u root
           命令成功执行后将进入到mysql命令提示符下:
           mysql>
           (以下命令均在mysql命令提示符下执行)
           改变当前数据库为mysql:
           use mysql
           设置从本地主机登录的root帐号密码:
           set password for root@localhost=password('your password');

4. 执行下面的命令使更改生效:
           flush privileges ;
           执行下面的命令退出mysql命令行:
           quit

5.验证装好了没有。
  
[root@iZ25phahu3aZ sbin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use infomation_schema;
ERROR 1049 (42000): Unknown database 'infomation_schema'
mysql> use information_schema;
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> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| GLOBAL_STATUS                         |
| GLOBAL_VARIABLES                      |
| KEY_COLUMN_USAGE                      |
| PARTITIONS                            |
| PLUGINS                               |
| PROCESSLIST                           |
| PROFILING                             |
| REFERENTIAL_CONSTRAINTS               |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| SESSION_STATUS                        |
| SESSION_VARIABLES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+---------------------------------------+
28 rows in set (0.00 sec)

mysql> select * from VIEWS;
Empty set (0.01 sec)

mysql> select * from SCHEMATA;
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| NULL         | information_schema | utf8                       | utf8_general_ci        | NULL     |
| NULL         | mysql              | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | test               | latin1                     | latin1_swedish_ci      | NULL     |
+--------------+--------------------+----------------------------+------------------------+----------+
3 rows in set (0.00 sec)



卸载mysql

    yum -y remove mysql*
然后清理

数据库目录
         /var/lib/mysql/
配置文件
         /usr/share /mysql(mysql.server命令及配置文件)
相关命令
         /usr/bin(mysqladmin mysqldump等命令)
启动脚本

         /etc/rc.d/init.d/(启动脚本文件mysql的目录)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值