Страница 1 из 2
Непонятно Mysql
Добавлено: 2008-02-23 13:03:07
RamzesII
Установил mysql не из портов путаюсь подсоеденится к базе а оно пишет:
Код: Выделить всё
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache2/htdocs/sql.php on line 11
Could not connect
а это скрипт которым проверяю
Код: Выделить всё
<?php
$link = mysql_connect("localhost", "root","admin") or die("Could not connect");
if( !$link ) die( mysql_error() );
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list))
{
echo "<h3>Database \"".$row->Database."\"</h3>\n";
$result = mysql_list_tables($row->Database);
if(!$result) die( "DB Error, could not list tables\n MySQL Error: ".mysql_error() );
else {
while ($row = mysql_fetch_row($result))
print "Table: $row[0]<br>";
mysql_free_result($result);
}
}
?>
Re: Непонятно Mysql
Добавлено: 2008-02-23 13:04:18
alex3
а он у тебя запущен? и дай my.cnf
Re: Непонятно Mysql
Добавлено: 2008-02-23 13:09:32
RamzesII
насчёт запущен незнаю
каким образом его запустить?
my.cnf
Код: Выделить всё
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is @localstatedir@) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Point the following paths to different dedicated disks
#tmpdir = /tmp/
#log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = @localstatedir@/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = @localstatedir@/
#innodb_log_arch_dir = @localstatedir@/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
Re: Непонятно Mysql
Добавлено: 2008-02-23 14:24:19
catdog_
Код: Выделить всё
echo mysql_enable=\"YES\" >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start / status
+ пора бы начать читать хендбук
+ чтобы коннектиться к базе из пхп, нада установить соответсвующие модули
Re: Непонятно Mysql
Добавлено: 2008-02-23 15:02:52
zg
catdog_ писал(а):Код: Выделить всё
echo mysql_enable=\"YES\" >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start / status
+ пора бы начать читать хендбук
так работать не будет потому как
RamzesII писал(а):Установил mysql не из портов
если mysql устанавливается как обычное приложение, то запускать нужно
но перед этим нужно ещё чё-то там запустить вроде скрипта по тестированию базы, я так и не разобрался, в INSTALL написано.
проверить работает ли MySQL можно так
Re: Непонятно Mysql
Добавлено: 2008-02-23 19:01:41
RamzesII
модули установлены в phpinfo() видна база mysql
Re: Непонятно Mysql
Добавлено: 2008-02-23 19:03:58
RamzesII
zg писал(а):catdog_ писал(а):Код: Выделить всё
echo mysql_enable=\"YES\" >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start / status
+ пора бы начать читать хендбук
так работать не будет потому как
RamzesII писал(а):Установил mysql не из портов
если mysql устанавливается как обычное приложение, то запускать нужно
но перед этим нужно ещё чё-то там запустить вроде скрипта по тестированию базы, я так и не разобрался, в INSTALL написано.
проверить работает ли MySQL можно так
это непомогло
пишет:
Код: Выделить всё
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Re: Непонятно Mysql
Добавлено: 2008-02-23 19:04:59
RamzesII
на эту команду ничего невыдаёт
Re: Непонятно Mysql
Добавлено: 2008-02-23 19:13:18
AzureZ
Re: Непонятно Mysql
Добавлено: 2008-02-23 19:29:41
RamzesII
Re: Непонятно Mysql
Добавлено: 2008-02-23 20:52:22
zg
RamzesII писал(а):
пишет нет такой команды
потому что она
в архиве есть файлик INSTALL, его очень желательно читать перед установкой

Re: Непонятно Mysql
Добавлено: 2008-02-23 21:23:01
zingel
а ещё есть чудная команда - env mysqld_safe &
Re: Непонятно Mysql
Добавлено: 2008-02-24 13:51:08
RamzesII
на эту команду вот что отвечает:
# /usr/local/mysql/bin/mysqld_safe &
Код: Выделить всё
[1] 1124
start# chown: mysql: Invalid argument
Starting mysqld daemon with databases from /usr/local/mysql/var
STOPPING server from pid file /usr/local/mysql/var/start.local.pid
080224 12:52:18 mysqld ended
[1] Done /usr/local/mysql/bin/mysqld_s
Re: Непонятно Mysql
Добавлено: 2008-02-24 13:53:25
Alex Keda
откуда ставил?
из портов или нет?
Re: Непонятно Mysql
Добавлено: 2008-02-24 14:12:26
RamzesII
нет не из портов из портов немогу требует инет
инет пока немогу настроить учюсь пока
вот решил с нета скачать и в ручную поставить
Re: Непонятно Mysql
Добавлено: 2008-02-24 14:13:07
RamzesII
может всётаки настроить нет и немучатся потом поставить из портов?
Re: Непонятно Mysql
Добавлено: 2008-02-24 14:45:06
paranoidchaos
пользователя, папки где базы будут лежать это всё создал ?
Re: Непонятно Mysql
Добавлено: 2008-02-24 14:56:32
RamzesII
нет а как?
Re: Непонятно Mysql
Добавлено: 2008-02-24 15:57:19
alex3
пора в хедбуке написать - если вы устанавливаете программу не из портов, прочтите наконец инструкцию|readme etc.
Re: Непонятно Mysql
Добавлено: 2008-02-24 20:07:05
zg
RamzesII писал(а):может всётаки настроить нет и немучатся потом поставить из портов?
тогда уж проще пакет скачать и не страдать пустой тратой времени
Код: Выделить всё
mysql-client-5.1.22.tbz ~1Mb
mysql-server-5.1.22.tbz ~4.7Mb
ставится за 20 секунд, после установки готов к работе. К слову, исходники весят в пять раз больше.
Re: Непонятно Mysql
Добавлено: 2008-02-24 20:29:00
serge
особо внимательней про distfiles
Re: Непонятно Mysql
Добавлено: 2008-02-24 20:58:52
RamzesII
где их скачать
Re: Непонятно Mysql
Добавлено: 2008-02-24 21:04:16
zg
RamzesII писал(а):где их скачать
я качал с
ftp://ftp.freebsd.org точную ссылку не дам, фтп-порт закрыт, тебе надо найти папку packages для твоей версии фри, либо
mysql-sever зависит от mysql-client, поэтому качать надо их оба одинаковой версии
Re: Непонятно Mysql
Добавлено: 2008-02-24 21:39:02
paranoidchaos
создай юзера и группу (тута под линукс аналогичные команды есть и под фришкой или юзай sysinstall шоб создать пользователя)
Код: Выделить всё
groupadd -g 27 mysql
useradd -u 27 -g 27 -s /bin/bash -M -r -d /var/lib/mysql mysql
конфигурируем
Код: Выделить всё
./configure \
--prefix=/usr/local \
--libexecdir=/usr/local/sbin \
--sysconfdir=/usr/local/etc \
--localstatedir=/var/lib/mysql \
--mandir=/usr/local/share/man \
--disable-shared \
--enable-assembler \
--with-thread-safe-client \
--with-mysqld-user="mysql" \
--with-unix-socket-path=/tmp/mysql.sock \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--without-readline \
--without-debug \
--without-docs \
--without-bench \
--with-charset=utf8 \
--with-extra-charsets=all
компилируем и устанавливаем
создаём папку /var/lib/mysql и устанавливаем права мускула на неё
Код: Выделить всё
cd /var/lib
mkdir mysql
chown mysql.mysql mysql
chmod 700 mysql
заходим в папку /usr/local/share/mysql и копируем файл my-medium.cnf в папку /usr/local/etc/my.cnf
Код: Выделить всё
cd /usr/local/share/mysql
cp my-medium.cnf ../../etc/my.cnf
после надо установить системную базу
после надо установить права мускула на эту базу
Код: Выделить всё
cd /var/lib/mysql
chown mysql.mysql *
cd mysql
chown mysql.mysql *
и запускаем
должно пройти всё без косяков тока что в опенвз поднял и всё норма
если есть косяки смотри логи в папке /var/lib/mysql/hostname.err
Re: Непонятно Mysql
Добавлено: 2008-02-26 10:33:42
RamzesII
спасибо получилось))
установил мускул апач и пхп всё работает единственное в phpinfo();
невидно базы думаю это нестрашно