安装$ sudo apt install mysql-server查看默认账号密码$ sudo cat /etc/mysql/debian.cnf # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = JRvfA0JiQGk5qhnz socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = JRvfA0JiQGk5qhnz socket = /var/run/mysqld/mysqld.sock修改密码$ mysql -udebian-sys-maint -pJRvfA0JiQGk5qhnzmysql>USE mysql; // mysql 5.7 mysql>UPDATE user SET plugin='mysql_native_password' WHERE User='root'; mysql>update mysql.user set authentication_string=password('xxx') where User='root' and Host='localhost'; // mysql 8.0 mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxx'; mysql>flush privileges; mysql>exit;
测试命令sysbench --test=oltp_read_write --tables=10 --table-size=1000000 --report-interval=10 --time=3600 --threads=50 --db-driver=mysql --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-password='xxxx' --mysql-db=sbtest run8.0.21 测试结果SQL statistics: queries performed: read: 15339058 write: 4382588 other: 2191294 total: 21912940 transactions: 1095647 (304.28 per sec.) queries: 21912940 (6085.57 per sec.) ignored errors: 0 (0.00 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 3600.8045s total number of events: 1095647 Latency (ms): min: 2.74 avg: 164.30 max: 5033.06 95th percentile: 707.07 sum: 180014353.79 Threads fairness: events (avg/stddev): 21912.9400/80.08 execution time (avg/stddev): 3600.2871/0.228.0.23 测试结果SQL statistics: queries performed: read: 2969064 write: 848304 other: 424152 total: 4241520 transactions: 212076 (58.89 per sec.) queries: 4241520 (1177.79 per sec.) ignored errors: 0 (0.00 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 3601.2587s total number of events: 212076 Latency (ms): min: 3.57 avg: 848.89 max: 6098.82 95th percentile: 1973.38 sum: 180029441.14 Threads fairness: events (avg/stddev): 4241.5200/32.35 execution time (avg/stddev): 3600.5888/0.34
清空日志mysql> reset master;查询是否开启了binlog$mysql -uroot -p mysql>use mysql; mysql> mysql> show variables like 'log_bin'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_bin | ON | +---------------+-------+ 1 row in set (0.01 sec)关闭binlog$sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf [mysqld] skip-log-bin # 添加 $sudo service mysql restart再次查看mysql> show variables like 'log_bin'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_bin | OFF | +---------------+-------+ 1 row in set (0.01 sec)
ubuntu默认安装apache是prefork模式，prefork内存消耗比较高。选者work模式好能提高并发的情况下，降低内存占用。event模式暂无经验，以后再研究。 1、安装apache2-work，php$sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid php5-cgi php5-cli php5-gd php5-mcryptphp5-cgi是将要被apache2的mod-fcgid调用的。 php5-cli是php的命令行 php5-gd php的图形处理支持。 php5-mcrypt phpmyadmin需要2、安装mysql$sudo apt-get install mysql-server php5-mysql3、配置apache2 fcig.conf,加入php映射。$sudo vi /etc/apache2/mods-available/fcgid.conf检查是否有以下两项,没有就添加。一般都有，ubuntu安装还是比较省事的。AddHandler fcgid-script .php FCGIWrapper /usr/lib/cgi-bin/php5 .php4、修改站点配置/etc/apache2/sites-available/下的所有站点配置文件。 中的Options选项后，添加+ExecCGI5、www下文件权限和所有者修正。 $chown -R www-data:www-data /var/www $chmod -R 755 /var/www 6、启用apache的rewirite apapche2安装后是没有开启rewirte的。$sudo a2enmod rewrite并修改站点配置的directory以下两项 Options FollowSymLinks //必须 AllowOverride All //必须 $sudo service apache2 restart
ubuntu apache2 phpmyadmin的关闭 $cd /etc/apache2/conf.d $sudo rm link phpmyadmin.conf -> ../../phpmyadmin/apache.conf $sudo service apache2 restart 数据库备份 mysqldump -u root -p --database dbName > dbName.sql 数据库表顺坏修复 需要先停掉mysql进程 $sudo service mysql stop $sudo myisamchk -r /var/lib/mysql/dbName/*.MYI