ubuntu 手动安装mysql
2014-04-25 23:11
330 查看
申请了一台云主机,需要手动安装所有环境,今天将mysql安装过程记下。
安装mysql
a. 下载不了gcc, 需要先运行apt-get update
b. cmake报错,每次要先删除cmakeCache.txt,再重新跑cmake
c. apt-get install ncurses找不到对应包,google后发现在Ubuntu中'ncurses-devel'是以'libncurses5-dev'命名的。
大致步骤如下
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql & [以safe模式启动mysql]
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
root@AY140420095828962476Z:/usr/local/mysql# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password' 设置密码
./bin/mysqladmin -u root -h AY140420095828962476Z password 'new-password'
Alternatively you can run:
./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.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe & 启动mysql
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl 全面检测mysql
Please report any problems with the ./bin/mysqlbug script!
============================================
安装完成后,发现mysql只能在本机连接,解决方法
1、改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
Sql代码
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
3、如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
Sql代码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Sql代码
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
注意授权后必须FLUSH PRIVILEGES;否则无法立即生效。
另外一种方法:
在安装mysql的机器上运行:
1、d:\mysql\bin\>mysql -h localhost -u root
//这样应该可以进入MySQL服务器
2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION
//赋予任何主机访问数据的权限
3、mysql>FLUSH PRIVILEGES
//修改生效
4、mysql>EXIT
//退出MySQL服务器
这样就可以在其它任何的主机上以root身份登录啦!
安装mysql
a. 下载不了gcc, 需要先运行apt-get update
b. cmake报错,每次要先删除cmakeCache.txt,再重新跑cmake
c. apt-get install ncurses找不到对应包,google后发现在Ubuntu中'ncurses-devel'是以'libncurses5-dev'命名的。
大致步骤如下
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql & [以safe模式启动mysql]
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
root@AY140420095828962476Z:/usr/local/mysql# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password' 设置密码
./bin/mysqladmin -u root -h AY140420095828962476Z password 'new-password'
Alternatively you can run:
./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.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe & 启动mysql
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl 全面检测mysql
Please report any problems with the ./bin/mysqlbug script!
============================================
安装完成后,发现mysql只能在本机连接,解决方法
1、改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
Sql代码
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
3、如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
Sql代码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Sql代码
GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
注意授权后必须FLUSH PRIVILEGES;否则无法立即生效。
另外一种方法:
在安装mysql的机器上运行:
1、d:\mysql\bin\>mysql -h localhost -u root
//这样应该可以进入MySQL服务器
2、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION
//赋予任何主机访问数据的权限
3、mysql>FLUSH PRIVILEGES
//修改生效
4、mysql>EXIT
//退出MySQL服务器
这样就可以在其它任何的主机上以root身份登录啦!
相关文章推荐
- Mysql主从复制之一主一从
- mysql数据库主从备份
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题
- 提高mysql 批量插入和更新性能
- MySQL Cookbook学习笔记第一章
- mysql触发器
- MySQL之Master-Master配置
- mysql表删除重复记录方法总结及效率对比
- MySQL是什么玩意儿(一)基本操作 分类: MySQL 2014-04-25 19:47 105人阅读 评论(0) 收藏
- nodejs 连接 mysql
- mysql 索引
- Mysql设置允许远程连接
- 关于mysql数据库的安装
- mysql 行长度
- mysql 数据库 vc 编程简单示例
- Mysql:向信号量添加给定计数将导致其超出它的最大计数 错误
- MySql 获取所有的表信息、字段信息
- MySQL服务无法启动(1067)问题
- mysql的使用
- 修改mysql数据表中的字段属性