首页 > 代码库 > php和mysql相关配置
php和mysql相关配置
1.php.ini的配置文件详解
ls /usr/local/php/etc/php.ini
/usr/local/php/bin/php -i|head
disable_functions =eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close
display_errors = Off(错误日志)
log_errors = On
error_log =/usr/local/php/logs/php_errors.log
mkdir /usr/local/php/logs/
chmod 777 /usr/local/php/logs/
error_reporting = E_ALL & ~E_NOTICE(452行)
vim /data/www/forum.php
ls /usr/local/php/logs
cat /usr/local/php/logs/php_errors.log
一个:open_basedir = /data/www:/tmp(限制到某个目录)
多个:vim /usr/local/apache/conf/extra/httpd-vhosts.conf
ServerName www.test.com
ServerAlias www.aaa.com
php_admin_value open_basedir "/data/www:/tmp"
2.php扩展模块如何安装
(查看模块) /usr/local/php/bin/php -m
cd /usr/local/src/php-5.4.36/ext
/usr/local/php/bin/php -m |grep -i curl(有没有curl这个模块)
/usr/local/php/bin/phpize(这是命令)
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
(扩展模块存放的目录)/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
vim /usr/local/php/etc/php.ini
extension=curl.so(885行)
/usr/local/php/bin/php -m (看curl是否加载进来)
或者grep ‘^extension=‘ /usr/local/php/etc/php.ini
3.mysql配置讲解(mysql调优:http://www.apelearn.com/bbs/thread-5758-1-1.html)
vim /etc/my.cnf
interactive_timeout = 8
wait_timeout = 8
long_query_time = 1
log_slow_queries = /data/mysql/slow.log
4.mysql的root密码重置
设置密码:mysqladmin -uroot password ‘xxr525970.‘
登录:mysql -uroot -pxxr525970.
重置密码:
vim /etc/my.cnf
加入skip_grant
/etc/init.d/mysqld restart
mysql->use mysql->update user set password=password(‘xxr525970.‘) where user=‘root‘;
去掉skip_grant
/etc/init.d/mysqld restart
5.远程登录mysql
mysql -uroot -h192.168.255.3 -P3306 -pxxr525970.
远程登录授权:
mysql -uroot -h127.0.0.1 -P3306 -pxxr525970.
grant all on *.* to ‘root‘@‘192.168.255.15‘ identified by ‘123456‘;
本地登录多个mysql:
mysql -uroot -S /tmp/mysql.sock -pxxr525970.
6.mysql常用操作
(有哪些库) show databases;
切换库:use 库名
查看使用的库:select database();
看表:show tables;
表里包含的字段:desc 表名
表的创建语句:show create table 表名\G;
创建库:use 库名
create database xxr;
创建表:
create table tb1(`id` int(4),`name` char(40)) ENGINE=MYISAM DEFAULT CHARSET=gbk;
插入数据:
insert into tb1 values(1,‘xie‘);
insert into tb1 (`id`) values(3);
insert into tb1 (`name`) values(‘haha‘);
更新数据:
update tb1 set id=2 where name= ‘xie‘;
删除一行:
delete from tb1 where name=‘xie‘
清空一个表:
truncate table xxr.tb1;
删除一个表:
drop table tb1;
删除一个库;
drop database xxr;
修复一个表:
repair table 表名;
刷新权限:flush privileges;
数据库队列:show processlist;
查看状态:show status like ‘‘;
查看mysql参数:show varizbles like ‘‘;
临时修改参数:set global 参数名;
7.mysql备份及恢复
mysqldump -uroot -p --default-character-set=gbk 库名 >位置;
mysql -uroot -p --default-character-set=gbk 库名 <位置;
本文出自 “linux运维” 博客,转载请与作者联系!
php和mysql相关配置