在Solaris 10 x86下安装MySQL说明

1、下载与操作系统对应的MySQL安装文件,推荐安装MySQl 5.5的pkg版本,下载地址:http://dev.mysql.com/downloads/mysql/  ,安装文件名:mysql-5.5.53-solaris10-x86_64.pkg.gz 。

以下操作均在root用户下执行:

2、在/home目录下新建目录mysql,将安装文件上传到/home/mysql 下。

3、将文件解压,可以在文件管理器中对文件点击右键解压缩,得到pkg文件mysql-5.5.53-solaris10-x86_64.pkg。

4、建立mysql用户组和mysql用户

# groupadd mysql

# useradd -G mysql mysql

用smc将mysql用户的密码设为“H9000mysql”,用户主目录设为/home/mysql。

在/home/mysql下新建一个文件夹data,用于存放数据库文件。

5、安装MySQL

# cd /home/mysql

# pkgadd -d ./mysql-5.5.53-solaris10-x86_64.pkg

安装过程中的选择项按照默认值或输入"y"即可。

注意安装完毕后的提示,需要指定root用户密码:

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/mysql/bin/mysqladmin -u root -h MNSDBS2 password 'new-password'

Alternatively you can run:
/opt/mysql/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.

6、进行数据库默认配置,对文件 /opt/mysql/mysql/support-files/my-medium.cnf 的下列部分进行修改:

[client]

default-character-set=gb2312

[mysqld]  
basedir=/opt/mysql/mysql
datadir=/home/mysql/data

[mysql]

default-character-set=gb2312

然后拷贝配置文件到/etc下

# cp /opt/mysql/mysql/support-files/my-medium.cnf /etc/my.cnf

7、修改文件夹权限

# chgrp -R mysql /opt/mysql/mysql

8、启动MySQL,修改root密码为“root”

# /etc/init.d/mysql start

# /opt/mysql/mysql/bin/mysqladmin -u root password 'root'

# /opt/mysql/mysql/bin/mysqladmin -u root -h MNSDBS2 password 'root'

 

9、建一个默认的数据库实例

 

# /opt/mysql/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql &

 

10、此时,可以用mysql命令登陆数据库了

# mysql -uroot -proot

 

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.53-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

10、开放远程访问root用户的权限,使其他机器的客户端可访问和配置数据库。执行如下SQL语句:

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

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> SET PASSWORD FOR root=PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

然后,就可以远程root登陆数据库了。

11、将数据库服务配置为开机自启动

把启动脚本文件mysql.server拷贝到文件夹/etc/init.d下

# cp /opt/mysql/mysql/support-files/mysql.server /etc/init.d/mysql.server

创建一个连接,使其在开机时自动执行

# ln /etc/init.d/mysql.server /etc/rc3.d/S99mysql

以上,安装完成。

posted @ 2016-10-20 16:28  pepperpie  阅读(420)  评论(0编辑  收藏  举报