oracle收购Mysql后,Mysql的安装配置方法

oracle收购Mysql后,Mysql的安装配置方法
现在在oracle官网上 下载的mysql有以下几个rpm包
MySQL-client-advanced
MySQL-devel-advanced
MySQL-embedded-advanced-5.6.14-1.rhel5.x86_64.rpm
MySQL-server-advanced-5.6.14-1.rhel5.x86_64.rpm
MySQL-shared-advanced-5.6.14-1.rhel5.x86_64.rpm
MySQL-shared-compat-advanced-5.6.14-1.rhel5.x86_64.rpm
MySQL-test-advanced-5.6.14-1.rhel5.x86_64.rpm
1、先把系统里安装的所有mysql找出来
#rpm -qa | grep -i mysql 运行此命令后,显示所有列表:
mysqlclient10-3.23.58-4.RHEL4.1
mysqlclient10-devel-3.23.58-4.RHEL4.1
2、将列表一一强制删除:
#rpm -ev --nodeps mysqlclient10-3.23.58-4.RHEL4.1
#rpm -ev --nodeps mysqlclient10-devel-3.23.58-4.RHEL4.1
3、将老版本的几个文件手工删除:
#rm -f /etc/my.cnf
#rm -rf /var/lib/mysql
#rm -rf/var/share/mysql
# rm -rf/usr/bin/mysql*
4.安装下载的版本的mysql,如上,
[root@oracle11 ~]#rpm -ivh MySQL-server-advanced-5.6.14-1.el6.x86_64.rpm
Preparing...               ########################################### [100%]
   1:MySQL-server-advanced  ###########################################[100%]
5.安装client
[root@oracle11 ~]#rpm -ivh MySQL-client-advanced-5.6.14-1.el6.x86_64.rpm
Preparing...               ########################################### [100%]
   1:MySQL-client-advanced  ###########################################[100%]
说明:不安装mysql-client是不能使用mysql工具登陆到mysql 数据库
6.oracle收购Mysql后,新版的 mysql刚安装完mysql后不能直接输入mysql登录数据库,而是设置了默认free password密码,默认密码放在了/root/.mysql_secret文件中,登陆后需要修改密码
安装完成后有这么一段话,
A RANDOMPASSWORD HAS BEEN SET FOR THE MySQL root USER !
You willfind that password in '/root/.mysql_secret'.
You must change thatpassword on your first connect,
no other statementbut 'SET PASSWORD' will beaccepted.
See the manual forthe semantics of the 'password expired' flag.
Also, the accountfor the anonymous user has been removed.
In addition, you canrun:
  /usr/bin/mysql_secure_installation
which will also giveyou the option of removing the test database.
This is stronglyrecommended for production servers.
See the manual formore instructions.
Please report anyproblems with the /usr/bin/mysqlbug script!
The latestinformation about MySQL is available on the web at
  http://www.mysql.com
Support MySQL bybuying support/licenses at http://shop.mysql.com
New default configfile was created as /usr/my.cnf and
will be used bydefault by the server when you start it.
You may edit thisfile to change server settings
7.修改密码
(1)查看文件寻找密码
[root@oracle11 ~]#vi /root/.mysql_secret
# The randompassword set for the root user at Mon Oct 28 11:09:39 2013 (local time): 3eriwUfI
(2)登陆Mysql
[root@oracle11 ~]#mysql -u root -p
Enter password:
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQLconnection id is 3
Server version:5.6.14-enterprise-commercial-advanced
Copyright (c) 2000,2013, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>
(3)修改密码
mysql> setpassword for 'root'@'localhost' = password ('root');
Query OK, 0 rowsaffected (0.05 sec)
当然也可以使用脚本 /usr/bin/mysql_secure_installation进行交互式的修改mysql的root密码,如下:
[root@oracle11 ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] n
... skipping.
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] n
... skipping.
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...

 

 

原文:http://www.2cto.com/database/201310/253698.html

转另一篇:http://www.111cn.net/database/mysql/50319.htm

MySQL查看用户权限的两种方法

ySQL查看用户权限命令的两方法:
 
一. 使用MySQL grants
 
使用方法:
mysql> show grants for username@localhost;实例:
 
mysql> show grants for root@localhost;
 +---------------------------------------------------------------------+
 | Grants for root@localhost                                           |
 +---------------------------------------------------------------------+
 | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
 +---------------------------------------------------------------------+
 1 row in set (0.01 sec)
 

二. 直接通过mysql select查询语句:

mysql> select * from mysql.user where user='test' and host='127.0.0.1' G;
 *************************** 1. row ***************************
                   Host: 127.0.0.1
                   User: test
               Password: *EB3C643405D7F53BD4BF7FBA98DCF5641E228833
            Select_priv: N
            Insert_priv: N
            Update_priv: N
            Delete_priv: N
            Create_priv: N
              Drop_priv: N
            Reload_priv: N
          Shutdown_priv: N
           Process_priv: N
              File_priv: N
             Grant_priv: N
        References_priv: N
             Index_priv: N
             Alter_priv: N
           Show_db_priv: N
             Super_priv: N
  Create_tmp_table_priv: N
       Lock_tables_priv: N
           Execute_priv: N
        Repl_slave_priv: N
       Repl_client_priv: N
       Create_view_priv: N
         Show_view_priv: N
    Create_routine_priv: N
     Alter_routine_priv: N
       Create_user_priv: N
             Event_priv: N
           Trigger_priv: N
 Create_tablespace_priv: N
               ssl_type:
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
            max_updates: 0
        max_connections: 0
   max_user_connections: 0
                 plugin: mysql_native_password
  authentication_string:
      password_expired: N
 1 row in set (0.00 sec)

可以看到Select_priv,Insert_priv,Update_priv…(www.111cn.net)等为N表示没有权限,该用户权限一目了然.
 
这时可以使用命令给用户加权限

grant all privileges on *.* to 'test'@'127.0.0.1' identified by 'passwd';
 flush privileges;另外:show可以看到很多东西:
 
show databases;
 show tables;
 show create database dbname;  // 这个可以看到创建数据库时用到的一些参数。
 show create table tablename;   // 可以看到创建表时用到的一些参数
 

还有另一篇安装blog 也转载一下:http://blog.csdn.net/shehun1/article/details/38827631

在Linux操作系统下,安装MYSQL有两种方式:一种tar安装方式,另外一种是rpm安装方式。这两种安装方式有什么区别呢?尽管我们在Linux下常用tar来压缩/解压缩文件,但MYSQL的tar格式的文件其实只是mysql的文件包,并不能直接安装,需要操作configure、make、install等命令才能完成安装,是一种比较繁琐的安装方式。而rpm格式的文件是真正的安装包,相当于windows的exe文件,可以直接安装。


    本文以MySQL-5.6.20 32位版本rpm格式的安装方式为例,详述MySQL的安装方式,64位的rpm版本安装方式也是如此。

    (一)删除老版本的MySQL
    在安装前要先确定系统是否已经安装了其他版本的MySQL,如已安装其他版本的MySQL,需先删除后再安装新版本。经本文亲测,采用如下方式删除老版本的MySQL或MySQL残留文件作为方便。
    1. 执行yum命令,删除MySQL的lib库,服务文件
yum remove  mysql mysql-server mysql-libs mysql-server;
    2. 执行find命令,查找MySQL的残留文件,然后运行“rm -rf 文件名”删除残留的MySQL文件
find / -name mysql
    (二)RPM格式安装MySQL

    当前,MySQL的最新版本为:5.6.20,从官网下载MySQL的rpm安装包,解压后有如下七个文件:
MySQL-client-advanced-5.6.20-1.el6.i686.rpm                          #MySQL客户端程序
MySQL-devel-advanced-5.6.20-1.el6.i686.rpm                            #MySQL的库和头文件
MySQL-embedded-advanced-5.6.20-1.el6.i686.rpm                  #MySQL的嵌入式程序
MySQL-server-advanced-5.6.20-1.el6.i686.rpm                          #MySQL服务端程序
MySQL-shared-advanced-5.6.20-1.el6.i686.rpm                        #MySQL的共享库
MySQL-shared-compat-advanced-5.6.20-1.el6.i686.rpm         #RHEL兼容包
MySQL-test-advanced-5.6.20-1.el6.i686.rpm                            #MySQL的测试组件

    一般对于开发而言,我们只需要下面三个文件就可以。

MySQL-client-advanced-5.6.20-1.el6.i686.rpm
MySQL-devel-advanced-5.6.20-1.el6.i686.rpm
MySQL-server-advanced-5.6.20-1.el6.i686.rpm
   
    1. 在重新进行安装之前,为确保万无一失,我们还是再确认一下系统中是否有MySQL极其相关的RPM安装包。如果有,则先删除。
rpm -qa | grep -i mysql
    执行完上述命令后,返回空数据,则可进行第二步。否则,执行下面的命令删除MySQL的相关包文件。
yum -y remove mysql-libs*
    2. 将前面提到的三个MySQL安装文件,拷贝到服务器,然后执行下述安装命令。
rpm -ivh MySQL-server-advanced-5.6.20-1.el6.i686.rpm
rpm -ivh MySQL-devel-advanced-5.6.20-1.el6.i686.rpm
rpm -ivh MySQL-client-advanced-5.6.20-1.el6.i686.rpm
    上述三个命令在执行时,只有第一个命令执行的时间稍微长些,后面两个命令运行速度很快。

    3.执行下述命令,将MySQL的配置文件拷贝到/etc目录下。
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
    4.分别运行下述命令,初始化MySQL及设置密码。
/usr/bin/mysql_install_db   #初始化MySQL
service mysql start     #启动MySQL
cat /root/.mysql_secret       #查看root账号的初始密码,会出现下述所示信息
# The random password set for the root user at Mon Aug 25 10:26:57 2014 (local time): ZFRmqNPoFH3aO5PU
mysql -uroot -pZFRmqNPoFH3aO5PU       #使用root账号登陆MySQL
set password=password('123456');   #更改MySQL密码,注意;不可少
exit   #退出
mysql -uroot -p123456           #使用新密码登陆
    5.配置允许远程登陆。
use mysql;
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *DFEB299B8A17E376E7804A115F471149953B5645 |
| chenxu | root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA |
| 127.0.0.1 | root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA |
| ::1 | root | *6E4C48EDF3CC66BC5F6E6C0980935C8ED660EFAA |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> update user set password=password('aqjccmtj') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4 Changed: 3 Warnings: 0

mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
    6.设置开机启动
[root@favccxx local]# chkconfig mysql on
[root@favccxx local]# chkconfig --list | grep mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
    上面打印出来的内容中,2~5为on就是开机启动了。

    7.修改/etc/my.cnf,设置MySQL的字符集,配置MySQL表明不区分大小写(默认情况下,MySQL对表名区分大小写,列名不区分大小写)。在[mysqld]下面加入如下内容:
character_set_server=utf8
character_set_client=utf8 
collation-server=utf8_general_ci
lower_case_table_names=1
max_connections=1000
    8.MySQL的默认文件路径
/var/lib/mysql/               #数据库目录
/usr/share/mysql              #配置文件目录
/usr/bin                     #相关命令目录
#启动脚本
    9.重启MySQL
[ root@favccxx local]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

    在Linux下安装MySQL是很简单的事情,但同时也是一种很繁琐的事情,谁让Linux上的操作大多数都要靠命令来完成呢。对于初学者来言,要记住所有的命令并不是多么明智的选择,最好的方法还是将一些常用的操作记录在笔记中。
 
mysql5.1版本的安装方法:转自: http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/11/04/2236240.html

1、准备安装程序(官方网站下载)

服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm

客户端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm

2、安装(打印信息略)


[root@localhost /]#rpm -ivh MySQL-server-community-5.1.44-1.rhel4.i386.rpm;

[root@localhost /]#rpm -ivh MySQL-client-community-5.1.44-1.rhel4.i386.rpm;

3、查看安装是否成功

[root@localhost /]#netstat -ntpl;

显示3306端口开放表示服务安装成功

4、测试连接

(*修改root密码)


[root@localhost /]#/usr/bin/mysqladmin -u root password 'xxxxxx';

[root@localhost /]#mysql -u root -p

Enter password:xxxxxx

出现mysql>表示登陆成功!

5、对mysql用户设置远程访问权限

方法1、改表法:登陆mysql后,更改“mysql”数据库里的“user”表里的“host”项,将“localhost”改“%”


mysql>use mysql;

mysql>update user set host ='%' where user ='root';

mysql>select host,user from user;

mysql>FLUSH PRIVILEGES

方法2、授权法:假设允许用户username通过密码password从远程连接到mysql服务器


mysql>GRANT ALL RRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

mysql>FLUSH PRIVILEGES;

6、安装目录结构

数据库目录:/var/lib/mysql/

配置文件:/usr/share/mysql(mysql.server命令及配置文件)

相关命令:/usr/bin(mysqladmin、mysqldump等命令)(*mysql的一种安全启动方式:/usr/bin/mysqld_safe  --user=root &)

启动脚本:/etc/rc.d/init.d/

7、停止/启动mysql服务


[root@localhost /]#service mysql stop;

[root@localhost /]#service mysql start;

8、修改字符编码

查看字符编码:


[root@localhost /]#show variables like 'character\_set\_%';

[root@localhost /]#show variables like 'collation_%';

停止mysql服务

将目录/usr/share/mysql下的文件my-medium.cnf拷贝到/etc/下并改名为my.cnf

打开my.cnf[client][mysqld]下面均加上default-character-set=utf8,并保存

*mysql5.5 改了字符集设置参数 character-set-server=utf8

重启mysql服务

9、卸载mysql

[root@localhost /]#rpm -qa|grep -i mysql

显示:


MySQL-server-community-5.1.44-1.rhel4.i386.rpm

MySQL-client-community-5.1.44-1.rhel4.i386.rpm

[root@localhost /]#rpm -e  MySQL-server-community-5.1.44-1.rhel4.i386.rpm

[root@localhost /]#rpm -e MySQL-client-community-5.1.44-1.rhel4.i386.rpm

删除残余文件

[root@localhost /]#rm -f /etc/my.cnf

[root@localhost /]#rm -f /var/lib/mysql

10、复制mysql数据库

源数据库名:source_db   用户名:root 密码:xxxxxx

目标数据库名:target_db   用户名:root 密码:xxxxxx 所在主机:221.218.9.41

shell>mysqldump source_db -uroot -pxxxxxx --opt | mysql target_db -uroot -pxxxxxx -h 221.218.9.41

 

你可能感兴趣的:(oracle收购Mysql后,Mysql的安装配置方法)