站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
CentOS/构建MySQL数据库服务器
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
==MySQL初始环境设定== [1]为MySQL的root用户设置密码 MySQL在刚刚被安装的时候,它的root用户是没有被设置密码的。首先来设置MySQL的root密码。 <pre>[root@sample ~]# mysql -u root ← 用root用户登录MySQL服务器 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select user,host,password from mysql.user; ← 查看用户信息 +------+------------------------------+---------------+ | user | host | password | +------+------------------------------+---------------+ | root | localhost | | ← root密码为空 | root | sample.centospub.com | | ← root密码为空 | | sample.centospub.com | | | | localhost | | +------+------------------------------+---------------+ 4 rows in set (0.00 sec) mysql> set password for root@localhost=password('在这里填入root密码'); ← 设置root密码 Query OK, 0 rows affected (0.01 sec) mysql> set password for root@'sample.centospub.com'=password('在这里填入root密码'); ← 设置root密码 Query OK, 0 rows affected (0.01 sec) mysql> select user,host,password from mysql.user; ← 查看用户信息 +------+--------------------------------+--------------------------+ | user | host | password | +------+--------------------------------+--------------------------+ | root | localhost | 19b68057189b027f | ← root密码被设置 | root | sample.centospub.com | 19b68057189b027f | ← root密码被设置 | | sample.centospub.com | | | | localhost | | +------+--------------------------------+--------------------------+ 4 rows in set (0.01 sec) mysql> exit ← 退出MySQL服务器 Bye</pre> 然后,测试一下root密码有没有生效。 <pre>[root@sample ~]# mysql -u root ← 通过空密码用root登录 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ← 出现此错误信息说明密码设置成功 [root@localhost ~]# mysql -u root -h sample.centospub.com ← 通过空密码用root登录 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ← 出现此错误信息说明密码设置成功 [root@sample ~]# mysql -u root -p ← 通过密码用root登录 Enter password: ← 在这里输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. ← 确认用密码能够成功登录 Your MySQL connection id is 5 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> exit Bye [root@sample ~]# mysql -u root -h sample.centospub.com -p ← 通过密码用root登录 Enter password: ← 在这里输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. ← 确认用密码能够成功登录 Your MySQL connection id is 6 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> exit ← 退出MySQL服务器 Bye</pre> [2] 删除匿名用户 在MySQL刚刚被安装后,存在用户名、密码为空的用户。这使得数据库服务器有无需密码被登录的可能性。为消除隐患,将匿名用户删除。 <pre>[root@sample ~]# mysql -u root -p ← 通过密码用root登录 Enter password: ← 在这里输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select user,host from mysql.user; ← 查看用户信息 +------+----------------------------+ | user | host | +------+----------------------------+ | | localhost | | root | localhost | | | sample.centospub.com | | root | sample.centospub.com | +------+----------------------------+ 4 rows in set (0.02 sec) mysql> delete from mysql.user where user=''; ← 删除匿名用户 Query OK, 2 rows affected (0.17 sec) mysql> select user,host from mysql.user; ← 查看用户信息 +------+----------------------------+ | user | host | +------+----------------------------+ | root | localhost | | root | sample.centospub.com | +------+----------------------------+ 2 rows in set (0.00 sec) mysql> exit ← 退出MySQL服务器 Bye</pre> [3] 删除测试用数据库 在MySQL被安装后,存在名为test的空数据库,将它删除。这里要注意的是,系统默认的还有一个名为mysql的数据库,它用于系统管理,所以请不要删除。 <pre>[root@sample ~]# mysql -u root -p ← 通过密码用root登录 Enter password: ← 在这里输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 to server version: 4.1.20 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; ← 查看系统已存在的数据库 +-------------+ | Database | +-------------+ | mysql | | test | +------------+ 2 rows in set (0.02 sec) mysql> drop database test; ← 删除名为test的空数据库 Query OK, 0 rows affected (0.07 sec) mysql> show databases; ← 查看系统已存在的数据库 +-------------+ | Database | +-------------+ | mysql | ← 确认名为test的数据库被删除,已不存在 +-------------+ 1 row in set (0.00 sec) mysql> exit ← 退出MySQL服务器 Bye</pre>
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)