mysql安装 + phpmyadmin 配置mysql管理界面

今天安装公司的内网mysql,顺便配置一下web管理界面,记下心得,分享出来。

===================================== linux mysql 安装 ====================================================

1、详见参考链接:

http://blog.csdn.net/wendi_0506/article/details/39478369

2、安装依赖包

yum install gcc gcc-c++ ncurses-devel perl  

3、编译安装选项 

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1   



PS:在完成拷贝

cp /usr/ local /mysql/support-files/my- default .cnf /etc/my.cnf  
需要姐注释并且修改 /etc/my.cnf 中 datadir 的值为  /data/mysqldb

====================================== 添加用户相关操作 ====================================================

MySql中添加用户,新建数据库,用户授权,删除用户,修改密码(注意每行后边都跟个;表示一个命令语句结束):

1.新建用户

  1.1 登录MYSQL:

  @>mysql -u root -p

  @>密码

  1.2 创建用户:

  mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));

  这样就创建了一个名为:test 密码为:1234 的用户。

注意:此处的"localhost",是指该用户只能在本地登录,不能在另外一台机器上远程登录。如果想远程登录的话,将"localhost"改为"%",表示在任何一台电脑上都可以登录。也可以指定某台机器可以远程登录。

  1.3 然后登录一下:

  mysql>exit;

  @>mysql -u test -p

  @>输入密码

  mysql>登录成功

 

2.为用户授权

  授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"; 

  2.1 登录MYSQL(有ROOT权限),这里以ROOT身份登录:

  @>mysql -u root -p

  @>密码

  2.2 首先为用户创建一个数据库(testDB):

  mysql>create database testDB;

  2.3 授权test用户拥有testDB数据库的所有权限(某个数据库的所有权限):

   mysql>grant all privileges on testDB.* to test@localhost identified by '1234';

   mysql>flush privileges;//刷新系统权限表

  格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码"; 

  2.4 如果想指定部分权限给一用户,可以这样来写:

  mysql>grant select,update on testDB.* to test@localhost identified by '1234';

  mysql>flush privileges; //刷新系统权限表

  2.5 授权test用户拥有所有数据库的某些权限:   

  mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

     //test用户对所有数据库都有select,delete,update,create,drop 权限。

  //@"%" 表示对所有非本地主机授权,不包括localhost。(localhost地址设为127.0.0.1,如果设为真实的本地地址,不知道是否可以,没有验证。)

 //对localhost授权:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。

 

3. 删除用户

   @>mysql -u root -p

  @>密码

   mysql>Delete FROM user Where User='test' and Host='localhost';

   mysql>flush privileges;

   mysql>drop database testDB; //删除用户的数据库

删除账户及权限:>drop user 用户名@'%';

        >drop user 用户名@ localhost; 

 

4. 修改指定用户密码

    @>mysql -u root -p

    @>密码

    mysql>update mysql.user set password=password('新密码') where User="test" and Host="localhost";

    mysql>flush privileges;

 

5. 列出所有数据库

  mysql>show database;

 

6. 切换数据库

  mysql>use '数据库名';

 

7. 列出所有表

  mysql>show tables;

 

8. 显示数据表结构

  mysql>describe 表名;

 

9. 删除数据库和数据表

  mysql>drop database 数据库名;

  mysql>drop table 数据表名;


//============================================ 给mysql 配置web界面,使用phpmyadmin ======================================================//

1、下载: http://www.phpmyadmin.net/home_page/index.php


2、下载完成后,放到服务器相应位置,并配置好nginx,我自己放到了/www/下,并改文件夹名字为admin.mysql.com


3、安装方式有两种,一种是直接修改config文件,一种是直接使用setup方式安装。下面只介绍 第一种方式

[root@dlodlo-server1 admin.mysql.com]# cp libraries/config.default.php config.ini.php

[root@dlodlo-server1 admin.mysql.com]#  chmod o+w config.inc.php 

修改 config.ini.php

$cfg['PmaAbsoluteUri'] = '你的域名'

$cfg['Servers'][$i]['host'] = 'localhost';         // MySQL hostname or IP address //填写localhost或mysql所在服务器的ip地址,如果mysql和该phpmyadmin在同一服务器,则按默认localhost 
$cfg['Servers'][$i]['port'] = '3306';                      // MySQL port - leave blank for default port //mysql端口,如果是默认3306,保留为空即可
$cfg['Servers'][$i]['user'] = 'root';                       // MYSQL 数据库用户名
$cfg['Servers'][$i]['password'] = '123456';          // MYSQL 数据库用户密码

$cfg['Servers'][$i]['auth_type'] = 'cookie'; 
|| 在此有四种模式可供选择,cookie,http,HTTP,config 
|| config方式即输入phpmyadmin的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。 
|| 当该项设置为cookie,http或HTTP时,登录phpmyadmin需要数据用户名和密码进行验证,,具体如下: 
|| PHP安装模式为Apache,可以使用http和cookie; 
|| PHP安装模式为CGI,可以使用cookie 

$cfg['blowfish_secret'] = '123456'; 
|| 如果认证方法设置为cookie,就需要设置短语密码,置于设置为什么密码,由您自己决定 ,但是不能留空,否则会在登录phpmyadmin时提示错误 

保存,此时就可以进入phpmyadmin的web页面了
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
进入数据库
首先先创建 给phpmyadmin使用的数据库,如下:
mysql> create database phpmyadmin;

然后创建一个mysql用户,给予其 数据库phpmyadmin的所有权限,如下创建 pma用户,密码123456:
mysql> use mysql;
mysql> grant all privileges on phpmyadmin.* to  pma@localhost indentified by '123456' ;
mysql> flush privilrges;

继续返回来修改 config.ini.php 文件:
$cfg['Servers'][$i]['controluser'] = 'pma';         //刚才上面创建的用户pma
$cfg['Servers'][$i]['controlpass'] = '123456';   // 刚才上面创建的pma用户的密码
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

进入 phpmyadmin 的web页面
在页面上会发现以下问题:
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated.  Find out why . 
      Or alternately go to 'Operations' tab of any database to set it up there.
点击 Find Out why, 出现 信息被禁用如下,
  Create  missing phpMyAdmin configuration storage tables.
$cfg['Servers'][$i]['pmadb'] ... 正常
$cfg['Servers'][$i]['relation'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['table_info'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['table_coords'] ... 错误
$cfg['Servers'][$i]['pdf_pages'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['column_info'] ... 错误
SQL 查询书签: 已禁用
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['bookmarktable'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['history'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['recent'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['favorite'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['table_uiprefs'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['tracking'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['userconfig'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['users'] ... 错误
$cfg['Servers'][$i]['usergroups'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['navigationhiding'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['savedsearches'] ... 错误
SQL 查询书签: 已禁用

$cfg['Servers'][$i]['central_columns'] ... 错误
SQL 查询书签: 已禁用


点击上面的 create, 会创建相应的数据表,创建好之后会如下

$cfg['Servers'][$i]['pmadb'] ... 正常
$cfg['Servers'][$i]['relation'] ... 正常
基本功能: 已启用

$cfg['Servers'][$i]['table_info'] ... 正常
显示功能: 已启用

$cfg['Servers'][$i]['table_coords'] ... 正常
$cfg['Servers'][$i]['pdf_pages'] ... 正常
Designer and creation of PDFs: 已启用

$cfg['Servers'][$i]['column_info'] ... 正常
显示字段注释: 已启用
浏览器转换: 已启用

$cfg['Servers'][$i]['bookmarktable'] ... 正常
SQL 查询书签: 已启用

$cfg['Servers'][$i]['history'] ... 正常
SQL 历史: 已启用

$cfg['Servers'][$i]['recent'] ... 正常
持久最近使用的表: 已启用

$cfg['Servers'][$i]['favorite'] ... 正常
Persistent favorite tables: 已启用

$cfg['Servers'][$i]['table_uiprefs'] ... 正常
持久表界面设置: 已启用

$cfg['Servers'][$i]['tracking'] ... 正常
追踪: 已启用

$cfg['Servers'][$i]['userconfig'] ... 正常
用户偏好: 已启用

$cfg['Servers'][$i]['users'] ... 正常
$cfg['Servers'][$i]['usergroups'] ... 正常
Configurable menus: 已启用

$cfg['Servers'][$i]['navigationhiding'] ... 正常
Hide/show navigation items: 已启用

$cfg['Servers'][$i]['savedsearches'] ... 正常
Saving Query-By-Example searches: 已启用

$cfg['Servers'][$i]['central_columns'] ... 正常
Managing Central list of columns: 已启用


, 会发现 phpmyadmin 这个数据库里面会创建了很多数据表,17张。

 此时需要继续修改 config.ini.php 配置文件。
找到类似于 一下的配置,把数据表的每一个表明添加上去,大概如下,
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig'; 

用户的 表 名可能不一样,请填写自己的表名称。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

完美搞定。























 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值