Linux 上安装MySQL安装

第一:Mysql下载地址:

http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-5.6.19-1.rhel5.x86_64.rpm-bundle.tar

第二:卸载原环境上的myql

查询原环境上安装的mysql

具体命令为:

rpm -qa|grep -i mysql

卸载相应的包:

rpm -e -v 具体的包名

如果有依赖关系或不止一个包则卸载方法为:

rpm -e  --allmatches --nodeps  mysql-5.0.77-4.el5_5.4 

第三:

解压相应的包

分别安装相应的包:

安装相应的包:

rpm -ivh 

rpm -qpi 

rpm -qpl

第四:

设置远程可以连接:

sudo /etc/init.d/mysqld stop      //关闭mysql
       mysqld_safe --user=mysql --skip-grant-tables --skip-networking &    
       mysql -u root mysql
       mysql> UPDATE user SET Password=PASSWORD('你想要的密码') where USER='root';
       mysql> FLUSH PRIVILEGES;
       mysql> quit
       sudo /etc/init.d/mysqld start
       mysql -uroot -p 你的密码

MySql远程连接数据库is not allowed to connect to this MySQL server


1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

Sql代码 复制代码

   1. mysql -u root -pvmwaremysql>use mysql; 

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

   3. mysql>select host, user from user; 

2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

Sql代码 复制代码

  1. GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH

      GRANT OPTION;  

  2.FLUSH   PRIVILEGES; 

 

 

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码

Sql代码 复制代码

   1. GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY  

   2. 'mypassword' WITH GRANT OPTION;  

   3. FLUSH   PRIVILEGES; 

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY

'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器的dk数据库,并使用mypassword作为密码

Sql代码 复制代码

   1. GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY  

   2. 'mypassword' WITH GRANT OPTION;  

   3. FLUSH   PRIVILEGES; 

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY

'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

注意授权后必须FLUSH PRIVILEGES;否则无法立即生效。

另外一种方法.

在安装mysql的机器上运行:

1、d:\mysql\bin\>mysql -h localhost -u root

//这样应该可以进入MySQL服务器

2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION

//赋予任何主机访问数据的权限

3、mysql>FLUSH PRIVILEGES

//修改生效

4、mysql>EXIT

//退出MySQL服务器

这样就可以在其它任何的主机上以root身份登录啦!

===============================================================================

遇到了 SQLException: access denied for  @'localhost' (using password: no)

解决办法   grant all privileges on *.* to identified by '1';

                  flush privileges;

拿  joe    1 登陆

附:

mysql> grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;

权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。
当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。
用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%'表示从任何地址连接。
‘连接口令’不能为空,否则创建失败。

mysql>grant select,insert,update,delete,create,drop on vtdc.employee to identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。

mysql>grant all privileges on vtdc.* to identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。

mysql>grant all privileges on *.* to identified by ‘123′;
给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

mysql>grant all privileges on *.* to identified by ‘123′;
给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。


2014-07-10 22:22:14 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-07-10 22:22:14 13321 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-07-10 22:22:14 13321 [Note] InnoDB: The InnoDB memory heap is disabled
2014-07-10 22:22:14 13321 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-07-10 22:22:14 13321 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-07-10 22:22:14 13321 [Note] InnoDB: Using Linux native AIO
2014-07-10 22:22:14 13321 [Note] InnoDB: Using CPU crc32 instructions
2014-07-10 22:22:14 13321 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-07-10 22:22:14 13321 [Note] InnoDB: Completed initialization of buffer pool
2014-07-10 22:22:14 13321 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-07-10 22:22:14 13321 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-07-10 22:22:14 13321 [Note] InnoDB: Database physically writes the file full: wait...
2014-07-10 22:22:14 13321 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-07-10 22:22:15 13321 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-07-10 22:22:16 13321 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-07-10 22:22:16 13321 [Warning] InnoDB: New log files created, LSN=45781
2014-07-10 22:22:16 13321 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-07-10 22:22:16 13321 [Note] InnoDB: Doublewrite buffer created
2014-07-10 22:22:16 13321 [Note] InnoDB: 128 rollback segment(s) are active.
2014-07-10 22:22:17 13321 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-07-10 22:22:17 13321 [Note] InnoDB: Foreign key constraint system tables created
2014-07-10 22:22:17 13321 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-07-10 22:22:17 13321 [Note] InnoDB: Tablespace and datafile system tables created.
2014-07-10 22:22:17 13321 [Note] InnoDB: Waiting for purge to start
2014-07-10 22:22:17 13321 [Note] InnoDB: 5.6.19 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2014-07-10 22:22:23 13321 [Note] Binlog end
2014-07-10 22:22:23 13321 [Note] InnoDB: FTS optimize thread exiting.
2014-07-10 22:22:23 13321 [Note] InnoDB: Starting shutdown...
2014-07-10 22:22:24 13321 [Note] InnoDB: Shutdown completed; log sequence number 1625977




2014-07-10 22:22:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-07-10 22:22:24 13344 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-07-10 22:22:24 13344 [Note] InnoDB: The InnoDB memory heap is disabled
2014-07-10 22:22:24 13344 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-07-10 22:22:24 13344 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-07-10 22:22:24 13344 [Note] InnoDB: Using Linux native AIO
2014-07-10 22:22:24 13344 [Note] InnoDB: Using CPU crc32 instructions
2014-07-10 22:22:24 13344 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-07-10 22:22:24 13344 [Note] InnoDB: Completed initialization of buffer pool
2014-07-10 22:22:24 13344 [Note] InnoDB: Highest supported file format is Barracuda.
2014-07-10 22:22:24 13344 [Note] InnoDB: 128 rollback segment(s) are active.
2014-07-10 22:22:24 13344 [Note] InnoDB: Waiting for purge to start
2014-07-10 22:22:24 13344 [Note] InnoDB: 5.6.19 started; log sequence number 1625977
2014-07-10 22:22:24 13344 [Note] Binlog end
2014-07-10 22:22:24 13344 [Note] InnoDB: FTS optimize thread exiting.
2014-07-10 22:22:24 13344 [Note] InnoDB: Starting shutdown...
2014-07-10 22:22:26 13344 [Note] InnoDB: Shutdown completed; log sequence number 1625987








A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.


You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.


Also, the account for the anonymous user has been removed.


In addition, you can run:


  /usr/bin/mysql_secure_installation


which will also give you the option of removing the test database.
This is strongly recommended for production servers.


See the manual for more instructions.


Please report any problems at http://bugs.mysql.com/


The latest information about MySQL is available on the web at


  http://www.mysql.com


Support MySQL by buying support/licenses at http://shop.mysql.com


New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值