`
angellin0
  • 浏览: 113824 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Solaris 10下Mysq安装及配置

阅读更多
1.准备安装前的工作
  创建mysql用户及用户组:
# groupadd -g 100 user
# useradd -m -g user -d /export/home/mysql mysql

  然后以mysql用户登陆。
2.下载mysql安装文件mysql-5.1.36-solaris10-i386.tar.gz到安装目录(如/export/home/mysql/works/)
  解压文件:
# chmod +x mysql-5.1.36-solaris10-i386.tar.gz (添加执行权限)
# gzip -d mysql-5.1.36-solaris10-i386.tar.gz
# tar -xvf mysql-5.1.36-solaris10-i386.tar

  安装初始数据库:
# cd works/mysql/scripts/
# ./mysql_install_db --user=mysql

  此时有可能会报错
FATAL ERROR: Could not find ./bin/my_print_defaults

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

重新执行命令,添加basedir及datadir参数:
# ./mysql_install_db --user=mysql --basedir=/export/home/mysql/works/mysql 
--datadir=/export/home/mysql/works/mysql/data/

执行成功。到此,Mysql已经安装成功了。

3.配置开机启动脚本


   修改support-files/mysql.server文件,添加basedir及datadir,然后将mysql.server文件复制到想要的位置如/etc/init.d/mysqld
# cp mysql.server /etc/init.d/mysqld

这样,启动、停止mysql服务的脚本为
# /etc/init.d/mysqld start | stop | restart [--user=mysql]
(按以上方式安装后user默认为mysql)

  可以在/etc/rc3.d/目录下建立开机启动脚本,文件名需要以“S”开头,然后跟数字,后面为自定义名字,如S86mysqlserv。文件内容为:
#!/sbin/sh
/etc/init.d/mysqld start

这样,当计算机重启后即可启动mysql服务。

4.修改root用户密码:

# mysqladmin -u root password root (修改root用户的密码为root)

  以命令行方式登录mysql:
#  mysql -u root -p

修改用户权限:
mysql> grant all PRIVILEGES on orion_expo.* to 
orion@'localhost' identified by '123456';

orion_expo 表示上面的权限是针对于哪个表的,orion_expo 指的是数据库,若为所有的则用*表示。由此可以推理出:对于全部数据库的全部表授权为“*.*”,对于某一数据库的全部表授权为“数据库名.*”,对于某一数据库的某一表授权为“数据库名.表名”。
orion@'localhost' 前面的orion表示你要给哪个用户授权,这个用户可以是存在的用户,也可以是不存在的用户。
    localhost 表示允许远程连接的 IP 地址,如果想不限制链接的 IP 则设置为“%”即可。
    123456 为用户的密码。
mysql> flush privileges; 


5. 常见错误


本地登录时出现错误:
ERROR 1251: Client does not support authentication 
protocol requested by server; consider upgrading MySQL client

这是因为客户端支持的mysql版本过低了,解决办法有以下两种:
(1)
mysql> SET PASSWORD FOR ‘some_user'@'some_host' = 
OLD_PASSWORD('newpwd');

(2)
mysql> UPDATE mysql.user SET Password = 
OLD_PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user';
mysql> FLUSH PRIVILEGES;

1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics