设为首页 加入收藏

TOP

linux安装mysql的glibc包(二)
2015-11-21 02:02:49 来源: 作者: 【 】 浏览:1
Tags:linux 安装 mysql glibc
mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+

好,数据库语言完毕。

▲打开mysql的远程访问
mysql默认是不允许远程访问的。
用密码登陆mysql,可以正常登陆,但是换台机器用工具连,就报错:
ERROR 1130: Host 192.168.1.6 is not allowed to connect to this MySQL server

方法: 改表法。mysql默认是不允许远程访问的,只能在localhost访问。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改成”%”

mysql -u root -p
Enter password: chang
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'; //可能会报错
mysql>flush privileges;
mysql>select host,user from user where user='root';

执行完上面的,就可以远程连接了!

注释:

update user set host = '%' where user = 'root'; //这个命令执行错误时,可能会报错:
ERROR 1062 (23000): Duplicate entry '%-root' for key 1;
解决方法:
1,不用管它。呵呵。
2,改成这样执行
update user set host='%' where user='root' and host='localhost';
也就是把localhost改成了所有主机。

---------------------------------------------------
之后运行app程序,报错:
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

解决办法是把/usr/local/mysql/lib下的
libmysqlclient_r.so.15
拷贝到/usr/lib解决。

至此,mysql安装配置完毕!

================= 我是华丽的分割线 ========================

----------------------------------------------------
■附注:
附注1: 重启和关闭mysql服务
重启mysql服务
:$ sudo /etc/init.d/mysql restart
关闭mysql服务
:$ sudo /etc/init.d/mysql stop
----------------------------------------------------
附注2: 非服务状态下,启动和停止mysql
启动mysql
代码:
:& cd /usr/local/mysql
:& bin/mysqld_safe --basedir=/usr/local/mysql --user=mysql &

停止mysql
代码:
:& cd /usr/local/mysql
:$ bin/mysqladmin -uroot -ppassw0rd shutdown

----------------------------------------------------
附注3: mysql命令行中文显示?号
mysql> set names utf8;

---------------------------------------------------
附注4: mysql的数据库存放路径
/var/lib/mysql

---------------------------------------------------
附注5: 从mysql中导出和导入数据
mysqldump 数据库名 > 文件名 #导出数据库
mysqladmin create 数据库名 #建立数据库
mysql 数据库名 < 文件名 #导入数据库

---------------------------------------------------
附注6: 修改mysql的root口令
sudo mysqladmin -u root -p password '你的新密码'

或者:括号里是新密码
use mysql;
update user set Password=password('chang') where User='root';
flush privileges;

---------------------------------------------------
附注7: 忘了mysql的root口令怎么办
sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
sudo mysqladmin -u user password 'newpassword
sudo mysqladmin flush-privileges

---------------------------------------------------
附注8: 输入要登录的mysql主机
./mysql -u root -h 127.0.0.1 -p


执行安全设置

#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):<---输入现在的root密码,因为我们还没设置,直接回车
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   <---是否设定root密码,当然设置了,输入Y回车
New password: <---输入root密码,并回车,输入的过程中不会有任何显示
Re-enter new password: <---再次输入root密码,并回车,输入的过程中不会有任何显示
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] Y <---是否删除匿名用户,删除,输入Y回车
 ... Success!
 
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] Y <---是否删禁止root用户远程登录,当然禁止,输入Y回车
 ... Success!
 
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] <---是否删除测试数据库test,删除,输入Y回车
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] Y <---刷新权限,输入Y回车
 ... Success!
 
Cleaning up...
 
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
 
Thanks for using MySQL!


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MySQL服务器关机进程 下一篇生产环境 xfs filesystem 上安装M..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: