CentOS 6安装MySQL及phpMyAdmin

来源:互联网 发布:round robin调度算法 编辑:程序博客网 时间:2024/05/17 06:53


1. CentOS 6安装MySQL

The recommended way to install MySQL on a Linux system is via RPM. 

MySQL-server-5.5.28-1.el6.i686.rpm - The MySQL database server, which manages databases and tables, controls
user access, and processes SQL queries.
MySQL-client-5.5.28-1.el6.i686.rpm - MySQL client programs, which makes it possible to connect to, and
interact with, the server.
MySQL-devel-5.5.28-1.el6.i686.rpm - Libraries and header files that come in handy when compiling other
programs that use MySQL.
MySQL-shared-5.5.28-1.el6.i686.rpm - Shared libraries for the MySQL client

rpm -ivh MySQL-server-5.5.28-1.el6.i686.rpm

This is optional but recommended step to install the remaining RPMs in the same manner:

rpm -ivh MySQL-client-5.5.28-1.el6.i686.rpm

rpm -ivh MySQL-devel-5.5.28-1.el6.i686.rpm 

rpm -ivh MySQL-shared-5.5.28-1.el6.i686.rpm


安装MySQL-server-5.5.28-1.el6.i686.rpm时若出现

conflicts with file from package mysql-libs-5.1.52-1.el6_0.1.x86_21的错误,则需删除mysql-libs,用rpm -e mysql-libs是删不掉的,因为很多依赖,试用

yum remove mysql-libs

即可删除。此时再安装rpm -ivh MySQL-server-5.5.28-1.el6.i686.rpm即可。


2. CentOS安装PhpMyAdmin

需要:

php-5.3.3-14.el6_3.i686.rpm

php-mysql-5.3.3-14.el6_3.i686.rpm

可通过yum在线安装。


到http://www.phpmyadmin.net/home_page/index.php下载PhpMyAdmin,文件如下:

phpMyAdmin-3.5.3-all-languages.zip


将其解压,设解压后最终的目录为phpmyadmin。将其移动到Apache web服务器所在的Web目录,即


注意Apache http服务器的默认端口为80.


配置如下:

(1)进入目录phpmyadmin中的libraries目录

找到 config.default.php文件copy份到上级目录,并命名为config.inc.php 

在config.inc.php中找到 $cfg['PmaAbsoluteUri'] 

修改你将用于让用户访问的phpMyAdmin的网址:
如:$cfg['PmaAbsoluteUri'] = 'http://localhsot/phpmyadmin/';

 或$cfg['PmaAbsoluteUri'] = 'http://localhsot:8899/phpmyadmin' (写出访问phpMyAdmin的绝对URL),此时Apache http的要改为8899,phpmyadmin一定要与Web目录下的目录名对应。

还有这些更改的地方:
$cfg['Servers'][$i]['host'] = 'localhost';(通常用默认,也有例外) 
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?用cookie。因为是网络上使用所以这里选择cookie 
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed自己机里不用设置)
注:$cfg['blowfish_secret'] = '';本机的话不需要设置,但是网络的话需要设置成cookie:
  $cfg['blowfish_secret'] = 'cookie'; 
设置完毕。 
(2)打开IE,输入http://localhost/phpmyadmin/(因具体设置的情况而定),输入用户名和密码后,用phpmyadmin浏览相应的mysql数据库;
如果设置$cfg['Servers'][$i]['auth_type'] = 'cookie'; 所以显示会要求输入帐号。 
(3)$cfg['DefaultLang'] = 'zh'; (这里是选择语言,zh代表简体中文的意思)


3 Ubuntu 安装PhpMyAdmin


Introduction

phpMyAdmin is a very famous MySQL mangement software package. To use it you should install and configure PHP, Apache and php mysql (or mysqli) extension seeApacheMySQLPHP for instructions.

Installing From Package

Install phpMyAdmin from the Universe repository see InstallingSoftware for detailed instructions on using repositories and package managers. (Note, however, that installation from a package manager often does not work).

From console:

sudo apt-get install phpmyadmin
  • If you're using Ubuntu 7.10 (Gutsy) or later select Apache2 from the "Configuring phpmyadmin" dialog box.

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf.

Include /etc/phpmyadmin/apache.conf
  • If you are using Ubuntu 9.04 (Jaunty), there is no need to modify /etc/apache2/apache2.conf as the package installer already copied the file phpmyadmin.conf into /etc/apache2/conf.d directory. You can also skip the set up step and go directly to http://<hostname>/phpmyadminand login with the user and password you set up during install.

Once phpMyAdmin is installed point your browser to http://localhost/phpmyadmin to start using it. You should be able to login using any users you've setup in MySQL. If no users have been setup, use admin with no password to login. 

Should you get a 404 "Not Found" error when you point your browser to the location of phpMyAdmin (such as: http://localhost/phpmyadmin) this is likely caused by not checking the 'Apache 2' selection during installation. To redo the installation run the following:

 sudo dpkg-reconfigure -plow phpmyadmin

Then select Apache 2 for the webserver you wish to configure.

If this does not work, then you can do the following to include the phpMyadmin-shipped Apache configuration into Apache: 

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.confsudo /etc/init.d/apache2 reload

Installing from source

You may install phpmyadmin from source. This method circumvents the package manager and you will need to install updates yourself. This is not recommended for a production web server. Also, you'll need to have Subversion installed to download the source.

To install it from source open the console and cd to the www directory using:

cd /var/www/

then download it using svn by writing:

sudo svn checkout https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/tags/STABLE/phpMyAdmin phpMyAdmin

then cd to phpMyAdmin

cd phpMyAdmin

and create the folder config

sudo mkdir config

after that chmod it

sudo chmod o+rw config

then open http://localhost/phpMyAdmin/setup/config.php and follow the instructions.

Assuming you used the setup.php file to setup phpMyAdmin, once you've finished configuring your mysql server and you've saved the changes, copy the config.inc.php file, auto-created in the config/ folder, out into the phpMyAdmin folder.. Make sure it's write-protected and delete the config/ folder.. Then refresh your browser.

If '#2002 cannot login to the mysql server' error occurs, change the value $cfg['Servers'][$i]['host'] in the config.inc.php from 'localhost' to '127.0.0.1'.



原创粉丝点击