-
-
Save Jamp/7b6aa391f4dcdc738b89391de2a8aa6f to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Run as root | |
set -e | |
apt-get update | |
apt-get install -y build-essential | |
apt-get install -y libncurses5-dev | |
useradd mysql | |
cd | |
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz | |
tar xzvf mysql-5.1.73.tar.gz | |
cd mysql-5.1.73 | |
./configure \ | |
'--prefix=/usr' \ | |
'--exec-prefix=/usr' \ | |
'--libexecdir=/usr/sbin' \ | |
'--datadir=/usr/share' \ | |
'--localstatedir=/var/lib/mysql' \ | |
'--includedir=/usr/include' \ | |
'--infodir=/usr/share/info' \ | |
'--mandir=/usr/share/man' \ | |
'--with-system-type=debian-linux-gnu' \ | |
'--enable-shared' \ | |
'--enable-static' \ | |
'--enable-thread-safe-client' \ | |
'--enable-assembler' \ | |
'--enable-local-infile' \ | |
'--with-fast-mutexes' \ | |
'--with-big-tables' \ | |
'--with-unix-socket-path=/var/run/mysqld/mysqld.sock' \ | |
'--with-mysqld-user=mysql' \ | |
'--with-libwrap' \ | |
'--with-readline' \ | |
'--with-ssl' \ | |
'--without-docs' \ | |
'--with-extra-charsets=all' \ | |
'--with-plugins=max' \ | |
'--with-embedded-server' \ | |
'--with-embedded-privilege-control' | |
make | |
make install | |
mkdir -p /etc/mysql | |
mkdir -p /var/lib/mysql | |
mkdir -p /etc/mysql/conf.d | |
echo -e '[mysqld_safe]\nsyslog' > /etc/mysql/conf.d/mysqld_safe_syslog.cnf | |
cp /usr/share/mysql/my-medium.cnf /etc/mysql/my.cnf | |
sed -i 's#.*datadir.*#datadir = /var/lib/mysql#g' /etc/mysql/my.cnf | |
chown mysql:mysql -R /var/lib/mysql | |
mysql_install_db --user=mysql | |
mysqld_safe -user=mysql & | |
/usr/bin/mysql_secure_installation | |
cp /usr/share/mysql/mysql.server /etc/init.d/mysql | |
chmod +x /etc/init.d/mysql | |
update-rc.d mysql defaults |
in step: /usr/bin/mysql_secure_installation if you got stuck:
you can apply these command the goes back:
chown mysql:mysql -R /var/lib/mysql
sudo chmod -R 755 /var/lib/mysql/
sudo service mysql start
I also got same issue,
mysql.cc: In function ‘void build_completion_hash(bool, bool)’:
mysql.cc:2669:37: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
field_names[i][num_fields*2]= '\0';
^~~~
anyone solved this issue:
mysql.cc: In function ‘void build_completion_hash(bool, bool)’:
mysql.cc:2687:37: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
field_names[i][num_fields*2]= '\0';
^~~~
Makefile:825: recipe for target 'mysql.o' failed
I'm having the same issue:
mysql.cc: In function ‘void build_completion_hash(bool, bool)’:
mysql.cc:2687:37: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
field_names[i][num_fields*2]= '\0';
^~~~
Makefile:825: recipe for target 'mysql.o' failed
make[2]: *** [mysql.o] Error 1
make[2]: Leaving directory '/home/andrestoga/mysql-5.1.73/client'
Makefile:556: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/andrestoga/mysql-5.1.73/client'
Makefile:495: recipe for target 'all-recursive' failed
I'm having the same issue:
mysql.cc: In function ‘void build_completion_hash(bool, bool)’:
mysql.cc:2687:37: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
field_names[i][num_fields*2]= '\0';
^~~~
Makefile:825: recipe for target 'mysql.o' failed
make[2]: *** [mysql.o] Error 1
make[2]: Leaving directory '/home/andrestoga/mysql-5.1.73/client'
Makefile:556: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/andrestoga/mysql-5.1.73/client'
Makefile:495: recipe for target 'all-recursive' failed
Any one can solving this problem?
To solve the "invalid conversion" error problem, try running configure
with CXXFLAGS="-fpermissive"
./configure --some-flag=whatever --another-flag=something CXXFLAGS="-fpermissive"
make
make install
Note for anyone who found this by googling, who might not be very familiar with compiling things: --some-flag=whatever --another-flag=something
are not real flags, just examples. You would replace them with real flags, such as --prefix=/usr
or anything else you want. Refer to the documentation/instructions you were reading about how to install an ancient version of mysql before you got sucked into researching this error.
Bonus
Once you've fixed that error, the compiler will be able to get further along, and you're likely to get another error about "narrowing", something like:
mysql.cc:1565:1: error: narrowing conversion of ‘18446744073709551615’ from ‘long unsigned int’ to ‘longlong’ {aka ‘long long int’} inside { } [-Wnarrowing]
It can be fixed by adding -Wno-narrowing
to your CXXFLAGS
. The whole thing would be
CXXFLAGS="-Wno-narrowing -fpermissive"
If you're using this build_mysql.sh
script, you can edit it so that those options are on the last line of the configure
command:
'--with-embedded-server' \
'--with-embedded-privilege-control' \
CXXFLAGS="-Wno-narrowing -fpermissive"
make
make install
In fact, it appears that there's a fork of the script that does exactly that:
https://gist.github.com/huangqiheng/7fbfcd7f4f97255447713ec6e9e85257
A Word of Caution
In the above examples, I've said that this "fixes" the problems. It actually just tells the compiler to ignore them. That's not great, but for many people it will suffice.
Other Possible Solutions
You could configure with -std=gnu++98
:
./configure blah-blah-blah CXXFLAGS="-std=gnu++98"
https://admin-pain.blogspot.com/2019/04/install-mysql-version-under-ubuntu.html
Or, for just the conversion error, you could patch mysql.cc
:
https://git.busybox.net/buildroot/commit/?id=94bad4fbf5759302a9f8f33267989d543f3a1167
Probably a stupid question but what directory should I be in to start this script? Anywhere special? Any one place better than another?
Thanks!
@RayNawara it doesn't particularly matter, because on line 11, it executes cd
with no arguments, which will change to the home directory of whatever user you're logged in as (likely /root
if you're running as root per the usage instructions on line 2) and it will do the remaining tasks from there.
@predators46 I think your problem is related to openwrt and gcc, not only mysql. I see you already tried asking on the openwrt forum and received no answers.
It looks like solution above ("patch mysql.cc") allowed you to get past the "narrowing conversion" error, but now you have a different problem. I don't know the answer, but try searching the web for "undefined reference to __sync_fetch_and_add_8". You are on a special journey, good luck.
How do I solve this problem?
mysql.cc: In function ‘void build_completion_hash(bool, bool)’:
mysql.cc:2669:37: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive]
field_names[i][num_fields*2]= '\0';
^~~~
thanks