怎么在ubuntu上安装两个mysql数据库

2022-07-30 科技 137阅读
apt-get install mysql-server
ubuntu操作系统
安装: apt-get install mysql-server
设置允许远程登录
修改/etc/mysql/my.cnf(此文件为mysql的配置文件)。将文件中的binding-address=127.0.0.1注释掉。
从本机登陆mysql:mysql -u root -p
use mysql;
设置允许所有主机连接到Mysql,执行命令:grant all privileges on *.* to root@"%" identified by "root用户的密码" with grant option;
重启mysql
/etc/init.d/mysql restart
*注:/etc/init.d/mysql start|stop|restart可以启动/停止/重启
设置开机自启动
把启动命令(/etc/init.d/mysql start)加入/etc/rc.local文件中
5
设置Mysql字符集:
创建数据库时指定字符集:create database mydb character set utf-8;
查看当前字符集:show variables like 'character%';
修改当前数据库的字符集:
mysql> SET character_set_client = utf8 ;mysql> SET character_set_connection = utf8 ;mysql> SET character_set_database = utf8 ;mysql> SET character_set_results = utf8 ;mysql> SET character_set_server = utf8 ;mysql> SET NAMES utf8; //这条语句会改变 character_set_client character_connection character_results这三个 的字符集
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com