A.3. Problemas relacionados con la instalación

MySQL 5.0

A.3. Problemas relacionados con la instalación

A.3.1. Problemas al enlazar a la biblioteca de clientes MySQL

When you are linking an application program to use the MySQL client library, you might get undefined reference errors for symbols that start with , such as those shown here:

/tmp/ccFKsdPa.o: In function `main':
/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'

You should be able to solve this problem by adding at the end of your link command, where represents the pathname of the directory where the client library is located. To determine the correct directory, try this command:

shell> mysql_config --libs

The output from mysql_config might indicate other libraries that should be specified on the link command as well.

If you get errors for the or function, add to the end of your link command and try again.

If you get errors for a function that should exist on your system, such as , check the manual page for the function in question to determine which libraries you should add to the link command.

You might get errors such as the following for functions that don't exist on your system:

mf_format.o(.text+0x201): undefined reference to `__lxstat'

This usually means that your MySQL client library was compiled on a system that is not 100% compatible with yours. In this case, you should download the latest MySQL source distribution and compile MySQL yourself. See Sección 2.8, “Instalación de MySQL usando una distribución de código fuente”.

You might get undefined reference errors at runtime when you try to execute a MySQL program. If these errors specify symbols that start with or indicate that the library can't be found, it means that your system can't find the shared library. The fix for this is to tell your system to search for shared libraries where the library is located. Use whichever of the following methods is appropriate for your system:

  • Add the path to the directory where is located to the environment variable.

  • Add the path to the directory where is located to the environment variable.

  • Copy to some directory that is searched by your system, such as , and update the shared library information by executing .

Another way to solve this problem is by linking your program statically with the option, or by removing the dynamic MySQL libraries before linking your code. Before trying the second method, you should be sure that no other programs are using the dynamic libraries.

A.3.2. Cómo correr MySQL como usuario normal

On Windows, you can run the server as a Windows service using normal user accounts beginning with MySQL 4.0.17 and 4.1.2. (Older MySQL versions required you to have administrator rights. This was a bug introduced in MySQL 3.23.54.)

On Unix, the MySQL server mysqld can be started and run by any user. However, you should avoid running the server as the Unix user for security reasons. In order to change mysqld to run as a normal unprivileged Unix user , you must do the following:

  1. Stop the server if it's running (use mysqladmin shutdown).

  2. Change the database directories and files so that has privileges to read and write files in them (you might need to do this as the Unix user):

    shell> chown -R  
    

    If you do not do this, the server is not able to access databases or tables when it runs as .

    If directories or files within the MySQL data directory are symbolic links, you'll also need to follow those links and change the directories and files they point to. might not follow symbolic links for you.

  3. Start the server as user . If you are using MySQL 3.22 or later, another alternative is to start mysqld as the Unix user and use the option. mysqld starts up, then switches to run as the Unix user before accepting any connections.

  4. To start the server as the given user automatically at system startup time, specify the username by adding a option to the group of the option file or the option file in the server's data directory. For example:

    [mysqld]
    user=
    

If your Unix machine itself isn't secured, you should assign passwords to the MySQL accounts in the grant tables. Otherwise, any user with a login account on that machine can run the mysql client with a option and perform any operation. (It is a good idea to assign passwords to MySQL accounts in any case, but especially so when other login accounts exist on the server host.) See Sección 2.9, “Puesta en marcha y comprobación después de la instalación”.

A.3.3. Problemas con permisos de ficheros

If you have problems with file permissions, the environment variable might be set incorrectly when mysqld starts. For example, MySQL might issue the following error message when you create a table:

ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)

The default value is . You can change this behavior by starting mysqld_safe as follows:

shell> UMASK=384  # = 600 in octal
shell> export UMASK
shell> mysqld_safe &

By default, MySQL creates database and directories with an access permission value of . You can modify this behavior by setting the variable. If you set its value, new directories are created with the combined and values. For example, if you want to give group access to all new directories, you can do this:

shell> UMASK_DIR=504  # = 770 in octal
shell> export UMASK_DIR
shell> mysqld_safe &

In MySQL 3.23.25 and above, MySQL assumes that the value for and is in octal if it starts with a zero.

See Apéndice E, Variables de entorno.